Read CSV and get details Powershell

Hello guys,

I would like to introduce you useful PowerShell scripts which help you retries data easier from Active Directory.

Sometimes the human resource needs update employees information on their HR Software, usually, they are doing it manually, and they even have not thought about the automatic process as we know.

For example, they should ask for a full list of all users with particular information, they already have it but it is very old, and they would like to know employees cities locations, not only they would like to know who lives in Tel Aviv or in NYC.

Their page should be like this:

Powershell_csv

As you can see, the file is very empty,

What you have to do is, first of all,  is to add  “write-host”  and see if there is something that should interrupt to our query:

import-csv “Path” | Write-host 

Powershell_write-host

We have “H1” that we have taken it into consideration,the next our step is the set variable for the path:

$path – import-csv c:\Users\Adinistrator\Desktop\userinfo.csv and then insert foreach command Foreach ($p in $path) { Get-Aduser -Filter {Office -eq $zubdubi} -properties * | select name,postalcode,office You have  to add | Export-csv c:\UserInfo.csv or txt -append -notypeinformation

 

Would you like to know how many users’ lives in specific countries? No problem

You have to run this:

$path – import-csv c:\Users\Adinistrator\Desktop\userinfo.csv Foreach ($p in $path) { Get-Aduser -Filter {Office -eq $zubdubi} -properties * | group office