I\'m still learning powershell, and so far I haven\'t found an answer on this website, despite a few searches. With Powershell being built on top of the .NET framework, can
Take a look at Add-Type cmdlet. It lets you write C# and other code in PowerShell. For example (from the above link),
C:\PS>$source = @"
public class BasicTest
{
public static int Add(int a, int b)
{
return (a + b);
}
public int Multiply(int a, int b)
{
return (a * b);
}
}
"@
C:\PS> Add-Type -TypeDefinition $source
C:\PS> [BasicTest]::Add(4, 3)
C:\PS> $basicTestObject = New-Object BasicTest
C:\PS> $basicTestObject.Multiply(5, 2)