Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Getting Local User SID from a list?

$
0
0

Hi Guys,

I'm afraid my scripting knowledge is not very strong and am trying to learn it as i go along.. but I'm stuck in the mud with something I'm trying to accomplish.

I'm using the below script I found on the net to get the SID for local user accounts, which works fine.

$objUser = New-Object System.Security.Principal.NTAccount("User1")
$strSID = $objUser.Translate([System.Security.Principal.SecurityIdentifier])	
$strSID.Value
$objUser,$strSID | out-file -filepath C:\test.txt

however I am wanting to do this with a list of local users which i have listed in a .csv file as:

user1

user2 etc.

I've then tried using something like this to get the SID for the whole list of local users, but it doesn't seem to be working for me.

$UserList=IMPORT-CSV C:\Users.csv

foreach($_ in $UserList)
	$strSID = $objUser.Translate([System.Security.Principal.SecurityIdentifier])	
	$strSID.Value
	$objUser,$strSID | out-file -filepath C:\test.txt

can anyone see where I'm going wrong... or advise me what format the .CSV file should be.

thanks in advance

C.


Regards Carlos Ferreira



Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>