{"id":3032,"date":"2018-12-03T10:48:18","date_gmt":"2018-12-03T09:48:18","guid":{"rendered":"https:\/\/www.mariotti.de\/?p=3032"},"modified":"2018-12-03T10:48:18","modified_gmt":"2018-12-03T09:48:18","slug":"powershell-funktionen-zur-user-sid-umwandkung","status":"publish","type":"post","link":"https:\/\/dev.mariotti.de\/?p=3032","title":{"rendered":"PowerShell Funktionen zur User <> SID Umwandkung"},"content":{"rendered":"<p>Kleine Samlung an Funktionen rund um das Thema User SID<\/p>\n<pre><code class=\"language-powershell\">function Get-SidFromName ($user) {\n    (New-Object System.Security.Principal.NTAccount($user)).Translate([System.Security.Principal.SecurityIdentifier]).Value\n}\n\nfunction Get-NameFromSid ($sid) {\n    (New-Object System.Security.Principal.SecurityIdentifier($sid)).Translate([System.Security.Principal.NTAccount]).Value\n}\n\nfunction Get-CurrentUserSid {\n    [System.Security.Principal.WindowsIdentity]::GetCurrent().User.Value\n}\n\nfunction Get-UserSidFromWildcard ($sid) {\n    ([ADSI]\"WinNT:\/\/$env:COMPUTERNAME\").Children | ?{$_.SchemaClassName -eq 'User'} | %{(New-Object Security.Principal.SecurityIdentifier($_.objectSid.Value, 0)).Value} | ?{$_ -like $sid}\n}\n\nfunction Get-GroupSidFromWildcard ($sid) {\n    ([ADSI]\"WinNT:\/\/$env:COMPUTERNAME\").Children | ?{$_.SchemaClassName -eq 'Group'} | %{(New-Object Security.Principal.SecurityIdentifier($_.objectSid.Value, 0)).Value} | ?{$_ -like $sid}\n}\n\nfunction Get-ServiceSidFromWildcard ($sid) {\n    ([ADSI]\"WinNT:\/\/$env:COMPUTERNAME\").Children | ?{$_.SchemaClassName -eq 'Service'} | %{(New-Object Security.Principal.SecurityIdentifier($_.objectSid.Value, 0)).Value} | ?{$_ -like $sid}\n}\n\nfunction Get-SidFromWildcard ($sid) {\n    ([ADSI]\"WinNT:\/\/$env:COMPUTERNAME\").Children | ?{'Group', 'User' -contains $_.SchemaClassName} | %{(New-Object Security.Principal.SecurityIdentifier($_.objectSid.Value, 0)).Value} | ?{$_ -like $sid}\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Kleine Samlung an Funktionen rund um das Thema User SID<\/p>\n","protected":false},"author":2,"featured_media":2425,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[37],"tags":[],"class_list":["post-3032","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell"],"_links":{"self":[{"href":"https:\/\/dev.mariotti.de\/index.php?rest_route=\/wp\/v2\/posts\/3032","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dev.mariotti.de\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dev.mariotti.de\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dev.mariotti.de\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/dev.mariotti.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3032"}],"version-history":[{"count":0,"href":"https:\/\/dev.mariotti.de\/index.php?rest_route=\/wp\/v2\/posts\/3032\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dev.mariotti.de\/index.php?rest_route=\/wp\/v2\/media\/2425"}],"wp:attachment":[{"href":"https:\/\/dev.mariotti.de\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3032"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dev.mariotti.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3032"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dev.mariotti.de\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3032"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}