First time working with scripting with Powershell. I need your help. I have completed an export of all users mail data to PST files for ingestion into a cloud archive solution. The cloud solution requires the PST files be in the "primarysmtpaddress" format (i.e. first.last@domain.com.pst)
Goal: The exported PST files are currently named by the "samAccountName" and need to be renamed to the associated primarysmtpaddress of that account.
In my lab I used the following script to export the mail data to PST by samaccountname to mirror what production data looks like.
foreach ($i in (Get-Mailbox -ResultSize Unlimited)) {New-MailboxExportRequest -Mailbox $i -FilePath \\exch2010mb\exports \$($i.samaccountname).pst}
The Rename Part:
The following one liner works perfectly but how do I get it to work for bulk changes? I need the primarysmtpaddress for each samaccountname formatted as first.last@domain.org.pst
Get-ChildItem c:\exports -Filter "bushgw.pst" | Rename-Item –NewName George.Bush@fake.org.pst
Any help is greatly appreciated.