Pellfrischmann
asked on
Powershell Export-Mailbox -PSTFolderPath
I would like to export a range off mailboxes to different variable folders i.e. c:\test\username\username. pst with out having to create a script for each user.
I have managed to get a script which looks up the mailboxes in a group and then exports to a specified location however I cannot get it to export to a folder variable using username and put the pst file inside this.
Get-user | where { $_.office -Eq "IT Services1" } | Export-Mailbox -PSTFolderPath ("C:\test\") -confirm:$false
Any help would be greatly appreciated.
Thanks
John
I have managed to get a script which looks up the mailboxes in a group and then exports to a specified location however I cannot get it to export to a folder variable using username and put the pst file inside this.
Get-user | where { $_.office -Eq "IT Services1" } | Export-Mailbox -PSTFolderPath ("C:\test\") -confirm:$false
Any help would be greatly appreciated.
Thanks
John
i don't think you need to do this as every pst file will get exported will have its mailbox alies which is uniqe
ASKER
Thats is correct however I would like it to put the pst file it a folder which is called the username i.e. c:\test\john\john.pst
But has the command looks up several email addresses so I need to use a variable to do this.
But has the command looks up several email addresses so I need to use a variable to do this.
Try this :
Get-user | where { $_.office -Eq "IT Services1" } | [string]$drive = "c:\test\" + $_.name; md $drive;Export-Mailbox -PSTFolderPath ($drive) -confirm:$false
Get-user | where { $_.office -Eq "IT Services1" } | [string]$drive = "c:\test\" + $_.name; md $drive;Export-Mailbox -PSTFolderPath ($drive) -confirm:$false
ASKER
Thanks but I get the following error.
Expressions are only permitted as the first element of a pipeline.
At c:\test\test3.ps1:1 char:91
+ Get-user | where { $_.office -Eq "IT Services1" } | [string]$drive = "c:\tes
t\" + $_.name; <<<< md $drive;Export-Mailbox -PSTFolderPath ($drive) -confirm:
$false
Expressions are only permitted as the first element of a pipeline.
At c:\test\test3.ps1:1 char:91
+ Get-user | where { $_.office -Eq "IT Services1" } | [string]$drive = "c:\tes
t\" + $_.name; <<<< md $drive;Export-Mailbox -PSTFolderPath ($drive) -confirm:
$false
sorry this one should work:
Get-user | where { $_.office -Eq "IT Services1" } | %{[string]$drive = "c:\test\" + $_.name; md $drive;Export-Mailbox -PSTFolderPath ($drive) -confirm:$false}
Get-user | where { $_.office -Eq "IT Services1" } | %{[string]$drive = "c:\test\" + $_.name; md $drive;Export-Mailbox -PSTFolderPath ($drive) -confirm:$false}
ASKER
Thanks again, nearly works as it creates the folder but then asks for the identity if typed in works fine
Directory: Microsoft.PowerShell.Core\ FileSystem ::C:\test
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 17/07/2009 17:09 John Smith
cmdlet Export-Mailbox at command pipeline position 1
Supply values for the following parameters:
Identity:
Directory: Microsoft.PowerShell.Core\
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 17/07/2009 17:09 John Smith
cmdlet Export-Mailbox at command pipeline position 1
Supply values for the following parameters:
Identity:
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks very much for your help.