1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
$Codigo = @" using System; using System.Runtime.InteropServices; namespace NS { public class Send { [DllImport("advapi32.dll")] public static extern bool GetUserName(System.Text.StringBuilder sb, ref Int32 length); } } "@ Add-Type $Codigo $size = 64 $str = [System.Text.StringBuilder]::new($size) [NS.Send]::GetUserName($str,[ref]$size) | Out-Null $str.ToString() |