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

Reading data from CSV file

$
0
0

I know I can get user data like this:  get-aduser 'MyID' | Select-Object name

But how do I display information I've read from a CSV file?   

$read=Import-Csv"U:\reports\ad\Employees.csv"
foreach ($recordin$read) {if ($record-like'*MyID*') {Select-Object$_. starsemail, $_. StarsDepartmentDesc | Write-Host$record

I've tried a few different things with $_.Starsemail (with/without a space).   I need to read a .CSV file and find out certain pieces of information, like email, department ID and department. then, once I have that I need to create a new OU (unless it is already there) based on Department ID and move the user into this new OU.  

Right now our AD is a mess.   We have all users in pretty much 1 OU so it makes it hard to perform many tasks.

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles