Convert PowerShell to C#

Convert PowerShell script to C#. This conversion process does not support converting cmdlets.