Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources: Active Threads
Viewing all articles
Browse latest Browse all 8411

Foreach assistence with import-csv

$
0
0

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:"

Am I going about this in the right way? I figure the foreach command is what I need just can't seem to get it right.
Thanks in advance to anyone who can assist.

Viewing all articles
Browse latest Browse all 8411

Latest Images

Trending Articles



Latest Images