Tuesday, September 1, 2015

PowerShell Script - Generate list of domain users and their Logon Script values

Yesterday I had cause to make some logon script changes.. Now we still use Batch files but in combination with PowerShell scripts and Group Policy Objects.  However a few years ago I made some test changes and discovered that I had not pushed those out to all users. *DOH*
The push currently to get everyone on the same page is DFS.  Distributed File System for those who don't know... We're preparing to make changes to some file servers and if all users are using DFS paths it'll be very easy.
Anyway below is the script I used to generate the text file with the data.

Get-AdUser -Filter * -Properties ScriptPath | ft Name, Scriptpath > C:\PathToFile\File.txt


Which resulted in A LOT of accounts that I don;t need to sift through.. ex-consultants, service accounts and the like. So I narrowed my field of search down a bit...


Get-AdUser -Searchbase "OU=blahblah,OU=blahblah,DC=Domain,DC=com" -filter * -properties ScriptPath | sort-object ScripPath | ft Name, ScriptPath > C:\PathToFile\File.txt




There you go, enjoy.





No comments:

Post a Comment