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

Tuesday, November 22, 2016

Rename the Default Mailbox database created during the exchange server 2013 installation.




Rename the Default Mailbox database created during the exchange server 2013 installation. 

Exchange server creates a mailbox database like "Mailbox Database XXXXXXXXXX, if you have used graphical mode or did not specify the database name in power-shell during exchange 2013 installation.  (In this installation Exchange created  "Mailbox Database 2040311832")
The mailbox database is located in the default path “C:\Program Files\Microsoft\Exchange Server\V15\Mailbox” 

Follow the below steps to rename and move the database to another path.

Get-Mailboxdatabase  "Mailbox Database 2040311832"  | Dismount-Database
It will prompt you to confirm. Click Yes to dismount the database. 

 

Use the below command to move the database to another path. I am moving the mailbox database to path "C:\MailboxDBs\MDB01.DB” and renaming the EDB to MDB01.edb. Also moving the Logs to folder  “C:\MailboxDBs\MDB01.LOG”

Move-DatabasePath "Mailbox Database 2040311832" -EdbFilePath "C:\MailboxDBs\MDB01.DB\MDB01.edb" -LogFolderPath "C:\MailboxDBs\MDB01.LOG"

Click on yes, when it asks for confirmation. 


Mount the database
Get-Mailboxdatabase  "Mailbox Database 2040311832"  | Mount-Database

Now the database is moved to the new path but the mailbox database display name is still showing the old name. You can use the below command to rename it

Get-Mailboxdatabase "Mailbox Database 2040311832" | Set-MailboxDatabase -Name "MDB01"
Or you can use graphical mode to rename it. 


Click on save to change the DB name.