Article Series published: Powershell für .NET-Entwickler

This post describes the article series about Powershell that I wrote for Windows Developer and shows a couple of samples.

The Windows Developer Magazin ( published my article series on Powershell for .NET Developers.

Die Grundlagen für die DevOps-Welt Teil 1: PowerShell für .NET-Entwickler

Entwickeln mit Power Shell-Unterstützung Teil 2: Praxisbeispiele aus dem DevOps-Alltag

Powershell Code Samples:

If interested, you can order it at:
A reading sample is available at:

The article introduces Powershell to the .NET developer and explains why it is a really powerful tool that can tremendously support your daily development activities.

Part 1: Die Grundlagen für die DevOps-Welt Teil 1: PowerShell für .NET-Entwickler

The article begins by introducing the help system integrated into Powershell. Did you know that you can open an external window with details to a command?

Get-Help Get-Process -ShowWindow


The article continues by covering the following topics:

  • CmdLets
  • Pipelines
  • Objects
  • Output Formatting
  • Result Filtering



Did you know that you can convert the results of a Powershell CmdLet to JSON, HTML, XML, or CSV? Just pipe to a ConvertTo- command:

dir | ConvertTo-Html | Out-File D:\files.html


Entwickeln mit Power Shell-Unterstützung Teil 2: Praxisbeispiele aus dem DevOps-Alltag

The second part of the articles covers advanced concepts:

  • Powershell Remoting
  • COM Interop
  • Windows Management Instrumentation (WMI)
  • Powershell Providers
  • Working with Sql Server
  • Working with IIS
  • Working with WebServices
  • Various Snippets
  • Powershell in the Browser for Microsoft Azure


Powershell Remoting

Powershell Remoting is REALLY powerful. With remoting you can work on a remote machine as if it was a local computer. There are two distinct modes. You can use Enter-PSSession to open a Powershell session on a remote machine or you can use Invoke-Command to send a command to one or MANY remote machines. The following snippet gets the first entry of the Security event log from the three machines LTMME05, LTMME06, LTMME07.

Invoke-Command -ComputerName LTMME05, LTMME06, LTMME07 -ScriptBlock {Get-EventLog Security -Newest 1}


COM Interop

Did you know that you can use COM interop to fill an Excel sheet with the currently running window services? Check the code at:


SOAP WebServices

Did you know that you can create a typed SOAP-WebService client in Powershell?

$uri = ''
$airportProxy = New-WebServiceProxy -Uri $uri -Namespace ws




REST WebServices

Calling REST Services is just as easy:

$uri = ''
$query = '?mode=driving&origin=Rheinstrasse 105, 64283 Darmstadt&destination=Rheinstrasse 66, 55116 Mainz'
$response = Invoke-RestMethod $uri$query


text    value
----    -----
35.0 km 35033

Powershell Providers

Powershell providers are a great feature. You might already know that you can navigate through the file system in Powershell. All the familiar commands from the DOS-Shell like “dir”, “cd”, “ren”, and so on still work in Powershell. However, these are NOT Powershell CmdLets. The CmdLets would be “Get-ChildItem” for “dir”, “Set-Location” for “cd” and “Rename-Item” for “ren”. So, how does this work?

Meet Powershell providers. A Powershell provider lets you navigate through a hierarchical structure. The FileSystemProvider is the default provider in Powershell. This is why the CmdLet “Get-ChildItems” lists the contents of the active directory. Powershell provides multiple providers. Enter Get-PSProviders for a list:

Name        Drives      
----        ------      
Registry    {HKLM, HKCU}
Alias       {Alias}     
Environment {Env}       
FileSystem  {C, D, Y, Z}
Function    {Function}  
Variable    {Variable}  
Certificate {Cert}      
WSMan       {WSMan}

Every provider lets you navigate through and modify hierarchical structures. The providers can be accessed by the use of abstractions called drives. If, for instance, you want to navigate through the HKEY_LOCAL_MACHINE tree in the registry, you can switch to the HKLM drive and navigate using dir, cd, …

PS C:\WINDOWS\system32> cd hklm:


Name                           Property
----                           --------
DriverDatabase                 Version : 167772160

In addition to the in-the-box providers, you can add others by using the import-module statement. You could for example explore the providers for Sql Server or IIS by either installing the products or by downloading their Powershell Modules. You need to import the module first and can then access the provider via drive:

PS C:\> Import-Module WebAdministration
PS C:\> Get-PSProvider

Name                 Capabilities
----                 ------------
Registry             ShouldProcess, Transactions
Alias                ShouldProcess
Environment          ShouldProcess
FileSystem           Filter, ShouldProcess, Credentials
Function             ShouldProcess
Variable             ShouldProcess
WebAdministration    ShouldProcess

PS C:\> cd IIS:
PS IIS:\> dir


PS IIS:\> dir .\AppPools\

Name                     State        Applications
----                     -----        ------------
.NET v4.5                Started
.NET v4.5 Classic        Started
CalculatorApplicationPoo Started
DefaultAppPool           Started      Default Web Site
MME                      Stopped
NewAppPool               Started
swimmingpool             Started