16Mar PowerShell - A note about using .NET & PowerShell together
I should’ve mentioned this in a previous post but I forgot - sorry. When you’re using the .NET assemblies in conjunction with PowerShell, for example when you want to control Windows services, you might sometimes receive a cryptic message that looks similar to the following.
Unable to find type [system.serviceprocess.servicecontroller]:
And then a note that you should make sure the assemblies are loaded. The way to do this is to add the following line to your PowerShell scripts before you make any calls to Get-Service, Stop-Service or any of the PowerShell service control stuff.
You don’t explicitly need to assign the results to a variable called $loadAssemblies. If you don’t though, the results of getting the assemblies will be shown on the screen like this - it’s pretty ugly which is why I assign the results to a variable in memory. I’ve deliberately trimmed and resized the screenshot to fit this blog’s theme but you get the idea.

The original article, PowerShell - Checking Windows services status, and the downloadable sample have been updated with this recommended change.

