Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Exporting to .pst using task scheduler (help with scripts)

$
0
0

Hello, I have this post in another topic but I thought I'd try the scripting guys.

I am trying to create a script that will run with the task scheduler to export my .pst files to a share folder. Here is what I have.

From what I understand, this script will open the exchange powershell and run my .ps1 file.

PowerShell.exe -PSConsoleFile "C:\Program Files\Microsoft\Exchange Server\V14\Bin\ExShell.psc1" -Command ". 'C:\Windows\Scripts\Exchange-Backup-1.ps1'"

Here is my .ps1 file

{foreach ($User in (Get-User | Where-Object {$_.Company -ilike "Company"}))} {foreach ($i in (Get-Mailbox))} New-MailboxExportRequest -Mailbox $i -FilePath "\\<servername>\PST\$($User.Alias).pst"

I am trying to select a group of people who have a specific property and also trying to name the files once exported with the proper alias name.I cannot quite figure it out. the error I get with this script is:

Missing statement body in foreach loop.
At line:1 char:76+ {foreach ($User in (Get-User | Where-Object {$_.Company -ilike "BGCA"} ) )  <<<< } {foreach ($i in (Get-Mailbox) ) }
New-MailboxExportRequest -Mailbox $i -FilePath "\\Apollo\PST\$($User.Alias).pst"+ CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException+ FullyQualifiedErrorId : MissingForeachStatement

I'd like to make sure that (1) these scripts will run using task scheduler and (2) the .ps1 script works.

Please help!


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>