Hello,
I’ve provided my company with a few scripts for a provisioning and out-processing Exchange 2010 mailboxes. It appears that there are large batches of work to do that are triggering a new Pshell process for each request, which is in turn using a lot of resources. I would like to refine the scripts to be more efficient. My thoughts were to run the scripts as jobs and close the process immediately, somehow have each task make use of an existing process, or maybe reuse an implicit remote session if that would help.
Any feedback is greatly appreciated!
Thanks,
Matt
Sorry, I’m quite new to pshell, and I didn’t think I would need to provide too much detail for this. We have an application that triggers a Pshell script. It’s being triggered very frequently and the number of Pshell processes are building up and stressing the server. I thought the answer may be along the lines of methods of using Pshell in general, rather than specific to a script. Exchange is a factor because of how you remote and use it’s cmdlets, so I included that. Here is the script. Let me know what else I can tell you.
==================================
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -command ". ‘C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1’; Connect-ExchangeServer -auto
If ((Get-Mailbox -identity $A).LitigationHoldEnabled){
If ($R = New-MailboxExportRequest -Name "$($A)-My-LitHold" -BatchName My-LitHold -Mailbox $A -FilePath \\server1\d$\folder1\$A-My-LitHoldExport.PST -AcceptLargeDataLoss -BadItemLimit 2147483647 | fl Status,Suspend,Name,FilePath,Mailbox,SourceDatabase | Out-String){
Send-MailMessage -From LitigationHoldExporter@domain.com -SmtpServer exchange.domain.com -To joe@domain.com -Subject "Litigation Hold Export Started for $($A)" -Body "Contact the Messaging Team to investigate any problems.
$R"
}
Else {Send-MailMessage -From LitigationHoldExporter@domain.com -SmtpServer exchange.domain.com -To joe@domain.com -Subject "Litigation Hold Export Started for $($A)" -Body "The Mailbox export failed to start for $($A). Forward this message to the Messaging Team to investigate.
$R"
}
}
Else{Write-Host "Mailbox $($a) is not on litigation hold"}
==================================