function CreateSubdirectory($path)
{
New-Item -ItemType Directory -Path $path
}
foreach ($group in get-adgroup -searchbase "OU=MyOU,DC=mydomain,DC=com" -filter *){
#create a subfolder $group.name
$sharepath="\\SERVER\SHARE" + $group.name
CreateSubdirectory $sharepath
foreach ($member in ($group.member | sort))
{
#create a folder for each memeber $member.name
CreateSubdirectory $sharepath + $member.name
}
}
Monday, September 26, 2011
AD Security Groups and Creating Folders on a Share with Powershell
The below script is used to loop through all security groups in a particuler OU in Active Directory and create a folder on the share for each group and then, inside that folder, create a separate folder for each member of that group.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment