Nytram
asked on
Exchange power shell
Hi Im running this and im sure its corrcet but its not running right so somthing is not right
Get-MailboxStatistics -Database “migrationtemp4¿ | where {$_.DisconnectReason -eq “SoftDeleted”} | foreach {Remove-StoreMailbox -Database $_.database -Identity $_.mailboxguid -MailboxState SoftDeleted}
Pipeline not executed because a pipeline is already executing. Pipelines cannot be executed concurrently.
+ CategoryInfo : OperationStopped: (Microsoft.Power...tHelper Runspace:E xecutionCm dletHelper Runspace) [],
PSInvalidOperationExceptio n
+ FullyQualifiedErrorId : RemotePipelineExecutionFai led
Get-MailboxStatistics -Database “migrationtemp4¿ | where {$_.DisconnectReason -eq “SoftDeleted”} | foreach {Remove-StoreMailbox -Database $_.database -Identity $_.mailboxguid -MailboxState SoftDeleted}
Pipeline not executed because a pipeline is already executing. Pipelines cannot be executed concurrently.
+ CategoryInfo : OperationStopped: (Microsoft.Power...tHelper
PSInvalidOperationExceptio
+ FullyQualifiedErrorId : RemotePipelineExecutionFai
ASKER
Hi
Not not working
Get-MailboxStatistics -Database "migrationtemp4" | where {$_.DisconnectReason -eq "SoftDeleted"} | Remove-StoreMailbox -Database $_.database -Identity $_.mailboxguid -MailboxState SoftDeleted
Cannot bind argument to parameter 'Database' because it is null.
+ CategoryInfo : InvalidData: (:) [Remove-StoreMailbox], ParameterBindingValidation Exception
+ FullyQualifiedErrorId : ParameterArgumentValidatio nErrorNull NotAllowed ,Remove-St oreMailbox
Invoke-Command : Cannot write input as there are no more running pipelines
At C:\Users\xxxxx.SU\AppData\ Roaming\Mi crosoft\Ex change\Rem otePowerSh ell\xxxx.x x.xx\xxx.x xx.xxx.ps
m1:40567 char:29
+ $scriptCmd = { & <<<< $script:InvokeCommand `
+ CategoryInfo : InvalidOperation: (:) [Invoke-Command], PSInvalidOperationExceptio n
+ FullyQualifiedErrorId : NoMoreInputWrite,Microsoft .PowerShel l.Commands .InvokeCom mandComman d
If I run Get-MailboxStatistics -Database "migrationtemp4" is run with the a full list of users stats
Martyn
Not not working
Get-MailboxStatistics -Database "migrationtemp4" | where {$_.DisconnectReason -eq "SoftDeleted"} | Remove-StoreMailbox -Database $_.database -Identity $_.mailboxguid -MailboxState SoftDeleted
Cannot bind argument to parameter 'Database' because it is null.
+ CategoryInfo : InvalidData: (:) [Remove-StoreMailbox], ParameterBindingValidation
+ FullyQualifiedErrorId : ParameterArgumentValidatio
Invoke-Command : Cannot write input as there are no more running pipelines
At C:\Users\xxxxx.SU\AppData\
m1:40567 char:29
+ $scriptCmd = { & <<<< $script:InvokeCommand `
+ CategoryInfo : InvalidOperation: (:) [Invoke-Command], PSInvalidOperationExceptio
+ FullyQualifiedErrorId : NoMoreInputWrite,Microsoft
If I run Get-MailboxStatistics -Database "migrationtemp4" is run with the a full list of users stats
Martyn
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I know this may be silly how do you run this?
You could break it to two lines and execute it from Exchange Management Shell, one line at a time.
$SDMailboxes = Get-MailboxStatistics -Database ““migrationtemp4" | where {$_.DisconnectReason -eq “SoftDeleted”}
$SDMailboxes | foreach {Remove-StoreMailbox -Database $_.database -Identity $_.mailboxguid -MailboxState SoftDeleted}
Please copy paste first line and then press enter. So the result will be stored $SDMailboxes variable. Then you should execute the second line.
Also you could create a script file by pasting the these two lines in a text file and saving it as a .ps1 file, for example you could name it 'RemoveSoftDeleted.ps1'. Then you could execute this script from Exchange Management Shell by browsing to the path where script is stored and then give the command .\RemoveSoftDeleted.ps1
We are adding the characters .\ in front of the script file name to execute it from Exchange Management Shell.
$SDMailboxes = Get-MailboxStatistics -Database ““migrationtemp4" | where {$_.DisconnectReason -eq “SoftDeleted”}
$SDMailboxes | foreach {Remove-StoreMailbox -Database $_.database -Identity $_.mailboxguid -MailboxState SoftDeleted}
Please copy paste first line and then press enter. So the result will be stored $SDMailboxes variable. Then you should execute the second line.
Also you could create a script file by pasting the these two lines in a text file and saving it as a .ps1 file, for example you could name it 'RemoveSoftDeleted.ps1'. Then you could execute this script from Exchange Management Shell by browsing to the path where script is stored and then give the command .\RemoveSoftDeleted.ps1
We are adding the characters .\ in front of the script file name to execute it from Exchange Management Shell.
Please try it without the foreach loop.
Get-MailboxStatistics -Database “migrationtemp4" | where {$_.DisconnectReason -eq “SoftDeleted”} | Remove-StoreMailbox -Database $_.database -Identity $_.mailboxguid -MailboxState SoftDeleted