SOLVED

Synd-MailPublicFolderSync Powershell script

%3CLINGO-SUB%20id%3D%22lingo-sub-84038%22%20slang%3D%22en-US%22%3ESynd-MailPublicFolderSync%20Powershell%20script%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-84038%22%20slang%3D%22en-US%22%3E%3CP%3EMy%20company%20are%20running%20a%20hybrid%20Exchange%202010%2FOffice%20365%20solution.%20We%20are%20syncronizing%20the%20public%20folders%20to%20Office%20365%20with%20the%20supported%20script%20Sync-MailPublicFolders.ps1.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20to%20run%20this%20manually%20to%20supply%20credentials%20and%20answer%20yes%20to%20a%20few%20questions%20while%20executing.%3C%2FP%3E%3CP%3EHas%20anyone%20an%20idea%20or%20done%20it%2C%20how%20to%20run%20this%20as%20an%20Schedueld%20Task%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-84038%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExchange%20Online%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EExchange%20Server%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Ehybrid%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-84110%22%20slang%3D%22en-US%22%3ERe%3A%20Synd-MailPublicFolderSync%20Powershell%20script%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-84110%22%20slang%3D%22en-US%22%3E%3CP%3EThe%20scipts%20accepts%20a%20Credential%20object%20as%20parameter%2C%20or%20you%20can%20simply%20edit%20it%20to%20get%20the%20credentials%20from%20a%20secure%20location%20(credentials%20manager%20or%20an%20encrypted%20file).%20There%20are%20multiple%20examples%20on%20how%20to%20achieve%20this%20for%20PowerShell%20scripts%26nbsp%3Bon%20the%20internet%2C%20do%20a%20search.%20Or%20you%20can%20just%20hardcode%20the%20username%2Fpassword%2C%20though%20I%20would%20not%20recommended%20this%20approach%20even%20if%20the%20machine%20on%20which%20you%20will%20run%20the%20script%20is%20tightly%20locked.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThen%20you%20simply%20invoke%20it%20as%20a%20scheduled%20task%2C%20again%20multiple%20examples%20on%20the%20internet.%20Here's%20the%20first%20example%20I%20got%3A%20%3CA%20href%3D%22https%3A%2F%2Fcommunity.spiceworks.com%2Fhow_to%2F17736-run-powershell-scripts-from-task-scheduler%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fcommunity.spiceworks.com%2Fhow_to%2F17736-run-powershell-scripts-from-task-scheduler%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Contributor

My company are running a hybrid Exchange 2010/Office 365 solution. We are syncronizing the public folders to Office 365 with the supported script Sync-MailPublicFolders.ps1.

 

I have to run this manually to supply credentials and answer yes to a few questions while executing.

Has anyone an idea or done it, how to run this as an Schedueld Task?

1 Reply
Highlighted
Best Response confirmed by Thomas Stensitzki (MVP)
Solution

The scipts accepts a Credential object as parameter, or you can simply edit it to get the credentials from a secure location (credentials manager or an encrypted file). There are multiple examples on how to achieve this for PowerShell scripts on the internet, do a search. Or you can just hardcode the username/password, though I would not recommended this approach even if the machine on which you will run the script is tightly locked.

 

Then you simply invoke it as a scheduled task, again multiple examples on the internet. Here's the first example I got: https://community.spiceworks.com/how_to/17736-run-powershell-scripts-from-task-scheduler