diff --git a/CreateDFSFolders.ps1 b/CreateDFSFolders.ps1 new file mode 100644 index 0000000..b31286b --- /dev/null +++ b/CreateDFSFolders.ps1 @@ -0,0 +1,27 @@ +#Path to the Projects folder in namespace root. +$path = "\\hq\CorporateData\Projects\" + +#Path to the targets where actual data is stored +$targetpaths = "\\CHIPVFS01\Projects\", "\\CHIPVFS02\Projects\" + +#Loop through each target path +foreach($targetpath in $targetpaths){ + + #Get all the subfolders in the target path + $folders= Get-ChildItem -Path $targetpath + + #Loop through each subfolder + foreach($folder in $folders){ + + #Construct the full path for the folder target + $folderpath = $path + $folder + + #Construct the full path for the target + $foldertargetpath = $targetpath + $folder + + #Create the folder with target + New-DfsnFolder -Path $folderpath -TargetPath $foldertargetpath + + } + +} diff --git a/SetHomeDirectory.ps1 b/SetHomeDirectory.ps1 new file mode 100644 index 0000000..ade0a4d --- /dev/null +++ b/SetHomeDirectory.ps1 @@ -0,0 +1,21 @@ +#path to the Users shared folder +$homepath = "\\hq\CorporateData\Users\" + +#initial OU where the script starts searching for the users +$basepath = "OU=Users,OU=ITLifeSkills,DC=hq,DC=itlifeskills,DC=local" +$users = Get-ADUser -SearchBase $basepath -Filter * + + +foreach($user in $users){ + #Get the current user identity + $identity = $user.SamAccountName + #Get the current user name + $name = $user.Name + + #construct the homedirectory path + $homedirectory = $homepath + $name + + #Update the current user with the new path to the Home directory. + Set-ADUser -Identity $identity -HomeDirectory $homedirectory +} +