We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
function Convert-SIDGUID { <# .SYNOPSIS This will help translate SIDS into GUIDS and vice versa. Checks if input is SID or GUID and returns the other.
.DESCRIPTION Based on code from https://tech.nicolonsky.ch/validating-a-guid-with-powershell/ and https://oliverkieselbach.com/2020/05/13/powershell-helpers-to-convert-azure-ad-object-ids-and-sids/ .PARAMETER InputObject The SID or GUID to convert #> param ( [Parameter(Mandatory = $true, Position = 0, ValueFromPipelineByPropertyName = $true)] [AllowEmptyString()] [string]$InputObject ) $tryguid = [guid]::TryParse($InputObject, $([ref][guid]::Empty)) if ($tryguid) { $bytes = [Guid]::Parse($ObjectId).ToByteArray() $array = New-Object 'UInt32[]' 4 [Buffer]::BlockCopy($bytes, 0, $array, 0, 16) $sid = "S-1-12-1-$array".Replace(' ', '-') return $sid } try { $sid = New-Object System.Security.Principal.SecurityIdentifier($InputObject) | foreach {$_.Value} $index = 'S-1-12-1-'.Length $length = $sid.length - $index $text = $sid.Substring($index,$length) # $text = $sid.Replace('S-1-12-1-', '') $array = [UInt32[]]$text.Split('-') $bytes = New-Object 'Byte[]' 16 [Buffer]::BlockCopy($array, 0, $bytes, 0, 16) [Guid]$guid = $bytes return $guid } catch { Return "No valid SID or GUID found" }
}
The text was updated successfully, but these errors were encountered:
No branches or pull requests
function Convert-SIDGUID {
<#
.SYNOPSIS
This will help translate SIDS into GUIDS and vice versa. Checks if input is SID or GUID and returns the other.
}
The text was updated successfully, but these errors were encountered: