-
-
Save diecknet/139e73a5ab027f38870bc20ffa9e4744 to your computer and use it in GitHub Desktop.
PsGetSid local machine SID implementation in PowerShell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-MachineSID { | |
# Going for the local SID by finding a local account and removing its Relative ID (RID) | |
$LocalAccountSID = Get-WmiObject -Query "SELECT SID FROM Win32_UserAccount WHERE LocalAccount = 'True'" |Select-Object -First 1 -ExpandProperty SID | |
$MachineSID = $LocalAccountSID -replace '-[^-]+$' | |
return $MachineSID | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment