Powershell script to pull users from an ad group and create folder with permissions
I saw a question that was similar however the answer they got was in vbscript. (PowerShell/Command Prompt - Create folders from AD group members)
I need to create a series of folders based on the mambership of an AD group.
I would like a powershell script so that I can get the users out of an ad group then create the folders on the Fileserver. I will then like to put permissions on those folders (I believe this is using get-acl and set-acl).
If anyone has any good book titles for learning powershell could you let me know also please?
Solution 1:
Books for ref materials:
Free Books:
- Dr. Tobias Weltner's Mastering Powershell
- Jeffrey Hicks' Powershell TFM (for PoSh v1)
- Keith Hill's Effective PowerShell
-
MS's PowerShell Owners Manual
There are tons more freebees, I'm just short on time...
Paid Books -
- Lee Holmes Windows PowerShell Cookbook
- Jeff Hicks & Don Jones new PowerShell TFM (for PoSh v2)
Hope this helps! And there are lots of others too. Ed Wilson has some do amazon search and read reviews and ask, it's a great community.
Solution 2:
I'm working on something similar, except the users already have folders on a file server, it's just in the wrong place, but not all are in the wrong place. I'm using Quest AD Management Shell to aide me and have gotten as far as scraping AD for users with the homeDirectory and homeDrive attribute and logging it into a CSV &/or HTML. Looks like this:
....change default otherwise it's 1000 or something like that
Set-QADPSSnapinSettings -DefaultSizeLimit 0
....grab users with homedrive and homedirectories and log to csv file
Get-QADUser | Where {$.'HomeDirectory' -ne $null -and $.'HomeDrive' -ne ''} | Select-Object -Property 'Name', 'HomeDrive', 'HomeDirectory' | Sort-Object Name | ConvertTo-CSV | Set-Content D:\scripts\Reports\HomeDrive.csv
....change ConvertToHTML | Set-Content blahblahblah.html for html file output