Friday, September 7, 2018

Create a multiple files in a folder using powershell

I want to create multiple files inside a folder. Suppose I want to name them from Benu1.csv , Benu2.CSV.. till Benu20.csv.
Also I want to put some content inside the files. Here I am writing Emailaddress as a value in the csv file.

You can create any type of file, use the file extension accordingly. Also you can increase/decrease the number of files you want.

1..20| foreach{New-Item -path c:\temp -ItemType File -Name "Benu$_.csv" -Value "EmailAddress"}

Monday, August 20, 2018

Get-ADuser when you know the email address only

Sometimes we get the email address as input and we have to get the AD account details for those users using PowerShell.

Try the below cmdlet.

Get-ADUser -Filter {emailaddress -like "benudhar.sahoo@contoso.com"} -Properties emailaddress