Convert SID to User Name using PowerShell

Create a SecurityIdentifier object and translate into a NTAccount: 1: $objSID = New-Object System.Security.Principal.SecurityIdentifier 1: (“S-1-5-21-3496554487-1900509739-3140548133-500”) 2: $objUser = $objSID.Translate( [System.Security.Principal.NTAccount]) 3: $objUser.Value

8

PowerShell Snippets Pt. 2

Some more PowerShell snippets. Is the IIS Running? function Check-IISServiceRunning{ try { $iisService = Get-Service W3SVC -ComputerName localhost } catch [ServiceCommandException] { throw “Check IIS service running FAILED. Please install IIS before continueing.” }} If you want to start it you can add: Start-Service -InputObject $iisService Install ASP.NET in the IIS? function Install-ASPNETIIS{ $aspNetRegIISDirectory =…


PowerShell Snippets Pt. 1

Below are a number of PowerShell snippets that I have find useful. This is just part 1. I will add more along the way. Running as Admin Often you need your script to run as admin – with this function you can check before hand that this is actually the case. function Check-RunningAsAdmin { $id=[System.Security.Principal.WindowsIdentity]::GetCurrent() $principal=New-ObjectSystem.Security.Principal.WindowsPrincipal($id) $administrator=[System.Security.Principal.WindowsBuiltInRole]::Administrator…