Using Install-WindowsFeature from a form

This topic contains 4 replies, has 2 voices, and was last updated by Profile photo of Adam Bertram Adam Bertram 3 years ago.

  • Author
    Posts
  • #16642
    Profile photo of Adam Bertram
    Adam Bertram
    Moderator

    I'm creating a form wrapper around a set of cmdlets. One of those cmdlets is Install-WindowsFeature. I'm trying to install the AS-NET-Framework, WDS and UpdateServices roles. I've confirmed both the .NET and WDS roles, when launched via my form always hang on 10%. This is a thread I found that is exactly what I'm seeing but no one there was able to help him.

    http://social.technet.microsoft.com/Forums/en-US/3d726b6f-d76a-401a-a8ff-120a8c126f63/powershell-with-winform-and-installwindowsfeature?forum=ITCG

    Has anyone here seen this behavior before?

  • #16643
    Profile photo of Don Jones
    Don Jones
    Keymaster

    You don't mention what OS you're using, but keep in mind that the ServerManager cmdlets in 2012+ use a certain amount of Remoting under the hood to do their job. That could be causing the hangup, possibly with a credential problem. It's also possible there's some interaction between WinForms and Write-Progress; you could try setting $ProgressPreference to SilentlyContinue to test that theory.

    We're not seeing a ton of folks trying to build GUIs around PowerShell tasks, which is one reason you're probably not seeing people answer that other question.

    Can you help me understand the larger task you're trying to complete? Maybe approaching this from a different direction might help. Do keep in mind that the whole WinForms thing isn't PowerShell's real "intended" use case, so it's not uncommon for weird stuff to crop up.

  • #16644
    Profile photo of Adam Bertram
    Adam Bertram
    Moderator

    Thanks, Don.

    I'm using 2012 R2 and, as always, every time I post a question on a forum I figure out how to do it. Sorry about that.

    I completely understand about the not using a GUI argument. I don't. This is for a client. I'm not sure why it was having a problem but I just fixed it by creating a separate script and launching a separate Powershell instance. This worked great. I know, it's a hack but it works and if the client is happy, I'm happy! 🙂

  • #16645
    Profile photo of Don Jones
    Don Jones
    Keymaster

    That was going to be my suggestion for getting it out of the WinForms context – either that, or launching the command in a job, which you can then check the status of. The WinForms stuff is a little janky. Sort of the more "forward looking" approach would be to have a jump server with a custom endpoint that you could call into from the form, so the form isn't actually running anything, but it sound slike that might not be an option here.

  • #16646
    Profile photo of Adam Bertram
    Adam Bertram
    Moderator

    Hmm..a job would be a cleaner way to do it. I'll look into that.

You must be logged in to reply to this topic.