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 | |
} |