Convert C# to PowerShell

Convert C# to PowerShell