From c4d521fe360f32bb4ff1158e1ee56713894c05e4 Mon Sep 17 00:00:00 2001 From: itlifeskills <106455363+itlifeskills@users.noreply.github.com> Date: Sun, 12 Jan 2025 11:55:25 -0600 Subject: [PATCH] Add files via upload --- CreateDFSFolders.ps1 | 27 +++++++++++++++++++++++++++ SetHomeDirectory.ps1 | 21 +++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 CreateDFSFolders.ps1 create mode 100644 SetHomeDirectory.ps1 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 +} +