Hello...I am somewhat new to the PS inner workings and thought I could ease my way into it by tackling, what I hoped, would be a simple starting project.
We have a multitude of AD users who, during the onboarding process, did not get home directories or drives assigned. The folders and permissions have actually been created so it's a somewhat simple process of using the set-aduser -homedirectory -homedrive.
I have exported the affected users into a txt file in which it just lists their name (which is their loginID). No filtering is needed on it. What I'm trying to do is create a variable called $name and have that pull the name of each item from the txt file and use in the get and set-aduser commands.
What I have so far is:
Import-Module ActiveDirectory
$namefile = "c:\scripts\homedirectory\users.txt"
$name = Import-Csv $namefile | foreach ??????
Get-ADUser -Identity $name |
Set-ADUser -HomeDirectory "\\server\path\$name" -HomeDrive "I:"