Using Install-WindowsFeature from a form

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.

Has anyone here seen this behavior before?

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.

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! :slight_smile:

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.

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