Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Get-SID
- {
- [CmdletBinding()]
- param
- (
- [Parameter(Mandatory=$true, Position=0)]
- [System.Object]$user
- )
- Try {
- $domain = $env:USERDOMAIN
- $objUser = New-Object System.Security.Principal.NTAccount("$domain","$user") -ErrorAction Stop
- $strSID = $objUser.Translate([System.Security.Principal.SecurityIdentifier])
- $strSID.Value
- Write-Host
- }
- Catch {
- Write-Error -Message 'Failed to get user SID.'
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement