qshinoの日記

Powershell関係と徒然なこと

実行ユーザー取得 by PowerShell

PowerShellで実行ユーザー取得

$id = [System.Security.Principal.WindowsIdentity]::GetCurrent()
$uname = $id.Name
$groupsids = $id.Groups
$groupsids | foreach{ $_.Translate([System.Security.Principal.NTAccount]) }

参考

WindowsIdentity

http://msdn.microsoft.com/ja-jp/library/system.security.principal.windowsidentity(v=vs.110).aspx

http://yomon.hatenablog.com/entry/2014/11/15/234529

http://yomon.hatenablog.com/entry/2014/11/15/234529