PowerShell Script to get Current User SID
- Christopher Tracy
- Aug 7, 2015
- 1 min read
Script below to get the CU SID and save it to an environment variable called USERSID.
#------------------------------------------------------------------------------
# http://v23c.com - 22-08-2015 # Script to get the SID of the Current Logged on User and save to environment variable #------------------------------------------------------------------------------ # Get Username from CU Environment variable $CurrentUser = Get-CU-SID ([Environment]::UserName) # Parse Function to get SID Set-Item -path env:USERSID -value ($CurrentUser) # Set USERSID CU Environment variable [Environment]::SetEnvironmentVariable("USERSID", $CurrentUser, "User") #------------------------------------------------------------------------------ # Function to get Current User SID #------------------------------------------------------------------------------ function Get-CU-SID { Param ( $CUIdentity ) $MyID = new-object System.Security.Principal.NTAccount($CUIdentity) return $MyID.Translate([System.Security.Principal.SecurityIdentifier]).toString() } #------------------------------------------------------------------------------ Enjoy
Recent Posts
See AllWe recently had an issue on site where a random couple of servers where experiencing Terminal Server Licence issue. The servers in...
After quite a few people grumbling about not being able to do much customisation of Task Manager within Windows, especially in a Citrix /...
The Script below can be used within AppSense Application Manager to check if the local machine is a member of a specific group. This can...
Comentarios