How do I retrieve the SID of a signed in remote user in my domain and assign to a variable in PowerShell? -
i think title sums up.
i typically use
gwmi win32_userprofile | select sid, localpath so can query full list of users on machine, trying streamline process remote computers. want enter computer name, check logged in user, use user account find associated sid. there want sid assigned variable can use other functions in script.
thanks in advance anyone's help.
i use username property in win32_computersystem wmi-class logged on user , convert result. use foreach-object-loop continue if there value (user logged in), stop without error if value blank (no user logged in). ex:
$currentusersid = get-wmiobject -class win32_computersystem | select-object -expandproperty username | foreach-object { ([system.security.principal.ntaccount]$_).translate([system.security.principal.securityidentifier]).value } ps c:\users\frode> $currentusersid s-1-5-21-333330555-1449773115-1111222333-1001
Comments
Post a Comment