So che stai cercando qualcosa che converta in qualche modo C# direttamente in PowerShell, ma ho pensato che fosse abbastanza vicino da suggerirlo.
In PS v1 è possibile utilizzare un .NET DLL compilata
PS> $client = new-object System.Net.Sockets.TcpClient
PS> $client.Connect($address, $port)
In PS v2 è possibile aggiungere codice C# direttamente in PowerShell e utilizzarlo senza 'conversione' utilizzando Add-Type (copiato direttamente da msdn)
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)
fonte
2010-01-27 01:20:55
Posso usare le mie librerie personalizzate C# con helper e classe utils? – Kiquenet
@JamesProgran Quanto è performante questo tipo di codice? –