SOLVED

Export to PST via Powershell

%3CLINGO-SUB%20id%3D%22lingo-sub-95007%22%20slang%3D%22en-US%22%3EExport%20to%20PST%20via%20Powershell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-95007%22%20slang%3D%22en-US%22%3E%3CP%3EI%20am%20continually%20expanding%20on%20my%20offboarding%20process%20within%20Orchestrator.%20I%20decided%20to%20add%20the%20export%20of%20the%20email%20so%20that%20all%20that%20has%20to%20be%20done%20is%20go%20to%20the%20Content%20search%20and%20download%20it%20(unless%20someone%20knows%20how%20to%20do%20that%20as%20well...).%20My%20addition%20works%2C%20however%2C%20instead%20of%20creating%20a%20single%20PST%20file%2C%20I%20end%20up%20getting%20the%20actual%20folders%20with%20individual%20email%20in%20message%20file%20format.%20I%20have%20tried%20what%20is%20correct%20per%20everything%20I%20could%20find%20(honestly%2C%20not%20a%20lot%20of%20detail%20on%20the%20subject).%20The%20current%20single%20line%20in%20question%20is%3A%3C%2FP%3E%3CPRE%3ENew-ComplianceSearchAction%20-SearchName%20%24SearchName%20-Export%20-ArchiveFormat%20PerUserPST%20-EnableDedupe%20%24true%20%3C%2FPRE%3E%3CP%3EI%20have%20tried%20different%20values%20for%20-ArchiveFormat%20including%20leaving%20it%20completely%20off%20since%20a%20single%20pst%20per%20user%20is%20supposed%20to%20be%20the%20default.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20will%20include%20the%20entire%20part%20of%20the%20script%20responsible%20for%20the%20full%20function%20in%20case%20it%20is%20supposed%20to%20be%20declared%20somewhere%20else%20(but%20I%20haven't%20found%20anything).%3C%2FP%3E%3CPRE%3E%23%20Create%20Compliance%20Search%20-%20Export%20Email%0A%0A%24SearchName%20%3D%20%22Export%20-%20%22%20%2B%20%24term.Name%0ANew-ComplianceSearch%20-ExchangeLocation%20%24term365.UserPrincipalName%20-Name%20%24SearchName%0A%0A%23%20Start%20Compliance%20Search%20and%20wait%20to%20complete%0A%0AStart-ComplianceSearch%20%24SearchName%0Ado%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20Start-Sleep%20-s%205%0A%20%20%20%20%20%20%20%20%24complianceSearch%20%3D%20Get-ComplianceSearch%20%24SearchName%0A%20%20%20%20%7D%0Awhile%20(%24complianceSearch.Status%20-ne%20'Completed')%0A%0A%23%20Create%20Compliance%20Search%20in%20exportable%20format%0ANew-ComplianceSearchAction%20-SearchName%20%24SearchName%20-Export%20-ArchiveFormat%20PerUserPST%20-EnableDedupe%20%24true%20%0A%24ExportName%20%3D%20%24SearchName%20%2B%20%22_Export%22%0A%0A%23Wait%20for%20Export%20to%20complete%0Ado%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20Start-Sleep%20-s%205%0A%20%20%20%20%20%20%20%20%24complete%20%3D%20Get-ComplianceSearchAction%20-Identity%20%24ExportName%0A%20%20%20%20%7D%0Awhile%20(%24complete.Status%20-ne%20'Completed')%3C%2FPRE%3E%3CP%3EAny%20help%20would%20be%20appreciated!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-95007%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3ECompliance%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EOffice%20365%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-444842%22%20slang%3D%22en-US%22%3ERe%3A%20Export%20to%20PST%20via%20Powershell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-444842%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F229846%22%20target%3D%22_blank%22%3E%40Tom%20Aguero%3C%2FA%3E%26nbsp%3BCan%20you%20share%20the%20whole%20script%20to%20download%20pst%20physically%20from%20EXO%20mailboxes%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-275502%22%20slang%3D%22en-US%22%3ERe%3A%20Export%20to%20PST%20via%20Powershell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-275502%22%20slang%3D%22en-US%22%3E%3CP%3EOh%20nice!%20I%20forgot%20I%20parsed%20that%20and%20didn't%20even%20think%20about%20polling%20the%20server-side%20progress.%3C%2FP%3E%3CP%3EThe%20only%20thing%20I%20can%20see%20being%20an%20issue%20is%20if%20it's%20a%20very%20large%20export%2C%20or%20you%20have%20a%20slow%20connection%2C%20your%20session%20with%20office%20365%20might%20timeout%20before%20it's%20done.%3C%2FP%3E%3CP%3EI'll%20try%20adding%20it%20to%20our%20implementation%20and%20see%20if%20I%20run%20into%20any%20problems.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAre%26nbsp%3Byou%20logging%20the%20entire%20session%20with%20a%20transcript%3F%20If%20not%2C%20I'd%20recommend%26nbsp%3Bwriting%20the%20progress%20to%20a%20file%20so%20you%20can%20quickly%20check%20if%20it%20finished%20or%20not%2C%20in%20case%20your%20computer%20restarts%20for%20windows%20updates%20or%20something%20while%20you're%20not%20looking.%20%22Write-Output%20%24Progress%20%7C%20Out-File%22%20is%20quick%20and%20easy%2C%20but%20you%20might%20want%20to%20include%20a%20timestamp%20as%20well.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-275453%22%20slang%3D%22en-US%22%3ERe%3A%20Export%20to%20PST%20via%20Powershell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-275453%22%20slang%3D%22en-US%22%3E%3CP%3EAwesome%2C%20I%20got%20it%20working%20and%20I%20figured%20out%20a%20way%20to%20monitor%20the%20process%20along%20with%20the%20percent%20complete.%20Sorry%2C%20I'm%20not%20sure%20how%20to%20do%20the%20fancy%20formatting%20for%20this%20post.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CBLOCKQUOTE%3E%3CP%3E%23Do%20while%20microsoft.office.client.discovery.unifiedexporttool.exe%20running%3CBR%20%2F%3E%24started%20%3D%20%24false%3CBR%20%2F%3EDo%20%7B%20%24status%20%3D%20Get-Process%20microsoft.office.client.discovery.unifiedexporttool%20-ErrorAction%20SilentlyContinue%3CBR%20%2F%3EIf%20(!(%24status))%20%7B%3C%2FP%3E%3CP%3EWrite-Host%20'Waiting%20for%20process%20to%20start'%20%3B%20Start-Sleep%20-Seconds%205%20%7D%3C%2FP%3E%3CP%3EElse%20%7B%3C%2FP%3E%3CP%3EWrite-Host%20'Process%20has%20started'%20%3B%20%24started%20%3D%20%24true%3C%2FP%3E%3CP%3E%7D%3C%2FP%3E%3CP%3E%7DUntil%20(%20%24started%20)%20%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EDo%7B%3C%2FP%3E%3CP%3E%24ProcessesFound%20%3D%20Get-Process%20%7C%20%3F%20%7B%24_.Name%20-like%20%22*unifiedexporttool*%22%7D%3CBR%20%2F%3EIf%20(%24ProcessesFound)%20%7B%20%24%3C%2FP%3E%3CP%3EProgress%20%3D%20get-ComplianceSearchAction%20-Identity%20%24exportname%20-IncludeCredential%20-Details%20%7C%20select%20-ExpandProperty%20Results%20%7C%20ConvertFrom-String%20-TemplateContent%20%24exporttemplate%20%7C%20%25%7B%24_.Progress%7D%3CBR%20%2F%3EWrite-Host%20%22Export%20still%20downloading%2C%20progress%20is%20%24Progress%2C%20waiting%2060%20seconds%22%3CBR%20%2F%3EStart-Sleep%20-s%2060%3C%2FP%3E%3CP%3E%7D%3C%2FP%3E%3CP%3E%7DUntil%20(!%24ProcessesFound)%3C%2FP%3E%3C%2FBLOCKQUOTE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-275326%22%20slang%3D%22en-US%22%3ERe%3A%20Export%20to%20PST%20via%20Powershell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-275326%22%20slang%3D%22en-US%22%3E%3CP%3EYes%2C%20this%20still%20worked%20quite%20well%20as%20of%20a%20week%20ago.%20I%20can%20only%20see%20this%20breaking%20if%20Microsoft%20changes%20the%20format%20of%20the%20%22Results%22%20property%20of%20the%20content%20search%20or%20splits%20it%20into%20separate%20properties%20of%20their%20own.%3C%2FP%3E%3CP%3EI%20haven't%20made%20any%20real%20improvements%20to%20it%2C%20but%20this%20reminds%20me%20that%20I%20should%20probably%20combine%20my%20code%20with%20Brad's%20so%20that%20there's%20a%20minimally%20functional%20example.%20I'll%20edit%20my%20previous%20post%20at%20some%20time%20for%20that.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20container%20URL%20comes%20from%20the%20%22%24exportdetails%20%3D%22%20line.%3C%2FP%3E%3CP%3EIt%20first%20gets%20the%20compliance%20search%2C%20selects%20the%20Results%20property%20that%20contains%20the%20container%20URL%2C%20then%20parses%20the%20URL%20and%20token%20from%20the%20property%20using%20the%20%24exporttemplate%3C%2FP%3E%3CP%3EThe%20results%20property%20is%20just%20one%20giant%20string%20of%20information%2C%20instead%20of%20separate%20properties%20of%20their%20own%2C%20so%20parsing%20it%20with%20Convert-FromString%20was%20the%20easiest%20way%20I%20could%20think%20of%20to%20get%20those%20properties.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EConvert-FromString%20requires%20a%20template%20consisting%20of%20at%20least%20two%20lines%20of%20data%2C%20formatted%20so%20that%20it%20knows%20what%20you're%20looking%20to%20parse.%20The%20data%20in%20%24exporttemplate%26nbsp%3Bis%20just%26nbsp%3Btwo%20of%20our%20old%20searches%2C%20modified%20with%20the%20parsing%20tags.%20Sorry%20if%20that's%20not%20incredibly%20clear.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-275299%22%20slang%3D%22en-US%22%3ERe%3A%20Export%20to%20PST%20via%20Powershell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-275299%22%20slang%3D%22en-US%22%3E%3CP%3EIs%20this%20still%20working%20for%20you%3F%20Have%20you%20made%20any%20changes%2Fimprovements%20since%20you%20posted%20this%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHow'd%20you%20get%20the%26nbsp%3Bcontainer%20URL%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-192375%22%20slang%3D%22en-US%22%3ERe%3A%20Export%20to%20PST%20via%20Powershell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-192375%22%20slang%3D%22en-US%22%3E%3CP%3EClickOnce%20has%20been%20deprecated%20by%20Google%20but%20is%20still%20supported%20in%20current%20builds...%20That's%20why%20it%20still%20works%20in%20the%20old%20interface%2C%20but%20it%20is%20blocked%20in%20the%20new%20interface.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-192372%22%20slang%3D%22en-US%22%3ERe%3A%20Export%20to%20PST%20via%20Powershell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-192372%22%20slang%3D%22en-US%22%3EYes%2C%20that's%20what%20I%20saw%20before%20clicking%20'Export'%20(second%20screen%20shot).%20When%20I%20clicked%20it%20I%20got%20the%20error%20box%20that%20complains%20about%20'failed%20to%20find%20parameter'.%20I%20was%20in%20IE%20when%20failing%20to%20export%20the%20results%20in%20the%20new%20UI.%20Trying%20a%20test%20export%20to%20get%20you%20a%20screen%20shot%20is%20failing%20now%20though.%20Apparently%20after%20one%20export%20went%20through%20others%20are%20working%20just%20fine%20in%20both%20browsers.%3CBR%20%2F%3E%3CBR%20%2F%3EAs%20for%20chrome%20not%20working%2C%20the%20ClickOnce%20extension%20still%20works%20for%20me.%20Is%20it%20failing%20for%20you%3F%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-192354%22%20slang%3D%22en-US%22%3ERe%3A%20Export%20to%20PST%20via%20Powershell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-192354%22%20slang%3D%22en-US%22%3E%3CP%3EContent%20search%20exports%20are%20different%20in%20the%20new%20experience.%20For%20one%20thing%2C%20you%20can%20no%20longer%20use%20Chrome%20to%20export%20search%20results%20because%20Google%20has%20deprecated%20the%20feature%20Microsoft%20used%20to%20download%20and%20launch%20the%20export%20app.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EBut%20I%20have%20certainly%20been%20able%20to%20export%20information%20from%20a%20content%20search.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F33891iFF38B584FF754308%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Search2.jpg%22%20title%3D%22Search2.jpg%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EExport%20from%20a%20content%20search%3C%2FSPAN%3E%3C%2FSPAN%3ELeading%20to%3A%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20678px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F33892i9F3E0FE911A24C2E%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Search3.jpg%22%20title%3D%22Search3.jpg%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EExport%20options%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EIsn't%20that%20what%20you%20see%20in%20the%20new%20experience%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-192329%22%20slang%3D%22en-US%22%3ERe%3A%20Export%20to%20PST%20via%20Powershell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-192329%22%20slang%3D%22en-US%22%3E%3CP%3EI%20hate%20to%20bring%20back%20old%20threads%2C%20but%20it's%20always%20nice%20to%20find%20info%20in%20threads%20that%20show%20up%20high%20on%20search%20results.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAs%20of%20today%20(05%2F10%2F2018)%20the%20export%20error%20still%20exists.%20However%2C%20swapping%20back%20to%20the%20%22old%20experience%22%20and%20using%20the%20export%20results%20link%20in%20the%20right%20column%20still%20works.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-142582%22%20slang%3D%22en-US%22%3ERe%3A%20Export%20to%20PST%20via%20Powershell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-142582%22%20slang%3D%22en-US%22%3E%3CP%3EOK.%20Then%20it's%20time%20to%20log%20a%20support%20call%20with%20Microsoft.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20too%20have%20some%20scripts%20that%20I%20use%20with%20searches.%20When%20I%20went%20to%20test%20one%20to%20investigate%20this%20problem%2C%20I%20also%20found%20that%20I%20had%20the%20wrong%20permissions%20and%20the%20export%20parameter%20wasn't%20available.%20After%20I%20amended%20permissions%20and%20restarted%20the%20PowerShell%20session%2C%20all%20was%20well...%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-142580%22%20slang%3D%22en-US%22%3ERe%3A%20Export%20to%20PST%20via%20Powershell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-142580%22%20slang%3D%22en-US%22%3EIt%20is.%20We%20have%20both%20been%20using%20a%20script%20to%20do%20this%20for%20some%20time.%20The%20error%20returned%20is%20that%20the%20export%20flag%20does%20not%20exist.%20I%20have%20exhaustively%20tested%20it.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-142555%22%20slang%3D%22en-US%22%3ERe%3A%20Export%20to%20PST%20via%20Powershell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-142555%22%20slang%3D%22en-US%22%3E%3CP%3ECheck%20that%26nbsp%3Bthe%26nbsp%3Baccount%20you%20use%20to%20log%20into%20PowerShell%20is%20a%20member%20of%20the%20Compliance%20Center%20eDiscovery%20Manager%20role%20group...%20The%20account%20needs%20to%20have%20this%20right%20to%20expose%20the%20Export%20function.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-142257%22%20slang%3D%22en-US%22%3ERe%3A%20Export%20to%20PST%20via%20Powershell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-142257%22%20slang%3D%22en-US%22%3E%3CP%3EI%20doubt%20it.%20The%20problem%20is%20that%20exported%20results%20are%20in%20temporary%20Azure%20storage%20that%20is%20accessed%20by%20a%20key.%20Handling%20that%20key%20in%20a%20secure%20manner%20to%20make%20it%20available%20and%20usable%20to%20a%20PowerShell%20cmdlet%20is%20something%20I%20do%20not%20think%20the%20developers%20have%20considered%20yet.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-142252%22%20slang%3D%22en-US%22%3ERe%3A%20Export%20to%20PST%20via%20Powershell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-142252%22%20slang%3D%22en-US%22%3EThank%20you!%3CBR%20%2F%3EDo%20you%20know%20if%20it%20Will%20je%20possible%20to%20download%20results%20through%20powershell%3F%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-142250%22%20slang%3D%22en-US%22%3ERe%3A%20Export%20to%20PST%20via%20Powershell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-142250%22%20slang%3D%22en-US%22%3E%3CP%3EThe%20compliance%20search%20functionality%20is%20being%20rewritten%20at%20present.%20This%20might%20have%20had%20the%20side-effect%20of%20removing%20the%20parameter.%20I%20have%20pinged%20the%20development%20team%20to%20ask.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-142133%22%20slang%3D%22en-US%22%3ERe%3A%20Export%20to%20PST%20via%20Powershell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-142133%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Brad%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20was%20having%20the%20exact%20same%20issue.%3C%2FP%3E%0A%3CP%3EI%20tried%20it%20on%20thuesday%20and%20it%20failed%20to%20find%20the%20parameter%3C%2FP%3E%0A%3CP%3ETried%20it%20on%20wednesday%20and%20it%20found%20the%20parameter%3C%2FP%3E%0A%3CP%3EI%20think%20they%20are%20activly%20working%20on%20the%20cmdlet.%20I%20wouldn't%20use%20it%20in%20the%20meanwhile.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-142132%22%20slang%3D%22en-US%22%3ERe%3A%20Export%20to%20PST%20via%20Powershell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-142132%22%20slang%3D%22en-US%22%3E%3CP%3EActually%2C%20even%20the%20export%20no%20longer%20works.%20I%20have%20currently%20opened%20a%20ticket%20with%20Office%20365%20to%20find%20out%20why.%20There%20is%3A%3C%2FP%3E%0A%3CP%3E%3CFONT%20color%3D%22%23f5f5f5%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E%3CFONT%20color%3D%22%23003366%22%3ENew-ComplianceSearchAction%20-SearchName%20%24SearchName%20-Export%3C%2FFONT%3E%20%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20color%3D%22%23ff0000%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3EA%20parameter%20cannot%20be%20found%20that%20matches%20parameter%20name%20'Export'.%20%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CLI-WRAPPER%3E%3C%2FLI-WRAPPER%3E%3C%2FP%3E%0A%3CP%3EThe%20updated%20help%20still%20shows%20the%20parameter%2C%20and%20the%20TechNet%20page%20has%20not%20been%20updated.%20However%2C%20search%20for%20it%26nbsp%3Bin%20the%20Command%20modules%20help%20in%20ISE%2C%20the%20check%20box%20for%20Export%20has%20now%20disappeared%20in%20the%20last%20week%20as%20well%20as%20the%20ArchiveFormat%20parameter.%20Can't%20find%20anything%20about%20it.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-142124%22%20slang%3D%22en-US%22%3ERe%3A%20Export%20to%20PST%20via%20Powershell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-142124%22%20slang%3D%22en-US%22%3E%3CP%3EI%20have%20searched%20a%20lot%20but%20I%20don't%20think%20there%20is%20a%20way%20to%20download%20it%20through%20PS%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-141591%22%20slang%3D%22en-US%22%3ERe%3A%20Export%20to%20PST%20via%20Powershell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-141591%22%20slang%3D%22en-US%22%3E%3CP%3EAre%20there%20eDiscovery%20PowerShell%20commands%20to%20do%20the%20export%3F%26nbsp%3B%20We%20want%20to%20export%20the%20content%20search%20results%20from%20eDiscovery%20content%20searches%20to%20a%20shared%20drive%20for%20investigators%20to%20access.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-141588%22%20slang%3D%22en-US%22%3ERe%3A%20Export%20to%20PST%20via%20Powershell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-141588%22%20slang%3D%22en-US%22%3EThis%20theme%20is%20the%20powershell%2C%20Please%20i%20need%20download%20Result%20of%20search%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-141559%22%20slang%3D%22en-US%22%3ERe%3A%20Export%20to%20PST%20via%20Powershell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-141559%22%20slang%3D%22en-US%22%3E%3CP%3EIn%20Compliance%20and%20Security%20center%20go%20to%20your%20export%20and%20click%20download%20on%20the%20right%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-141486%22%20slang%3D%22en-US%22%3ERe%3A%20Export%20to%20PST%20via%20Powershell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-141486%22%20slang%3D%22en-US%22%3E%3CP%3Eonce%20exported%20how%20can%20I%20download%20the%20PST%2C%20please%20your%20urgent%20help%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-141409%22%20slang%3D%22en-US%22%3ERe%3A%20Export%20to%20PST%20via%20Powershell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-141409%22%20slang%3D%22en-US%22%3E%3CP%3EBrad%20to%20the%20rescue%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-141408%22%20slang%3D%22en-US%22%3ERe%3A%20Export%20to%20PST%20via%20Powershell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-141408%22%20slang%3D%22en-US%22%3EThank%20you%20for%20the%20answer.%3CBR%20%2F%3EI%20was%20indeed%20looking%20for%20a%20way%20to%20physical%20exporting%20for%20the%20search.%20Guess%20I%20will%20have%20to%20do%20that%20manually.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-141406%22%20slang%3D%22en-US%22%3ERe%3A%20Export%20to%20PST%20via%20Powershell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-141406%22%20slang%3D%22en-US%22%3E%3CP%3ETo%20clarify%2C%20everything%20up%20to%20the%20physical%20exporting%20can%20be%20scripted%20with%20basic%20existing%20cmdlets.%20To%20do%20the%20actual%20export%2C%20you%20would%20have%20to%20write%20some%20additional%20code%20to%20do%20this%20via%20the%20GUI%2C%20as%20there%20is%20currently%20no%20cmdlet%20to%20grab%20the%20export%20and%20save%20it%20locally.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHere%20is%20the%20scriplet%20regarding%20this%20function%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20color%3D%22%23006400%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E%23%20Create%20Compliance%20Search%20-%20Export%20Email%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20color%3D%22%23ff4500%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E%24SearchName%3C%2FFONT%3E%20%3CFONT%20color%3D%22%23a9a9a9%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E%3D%3C%2FFONT%3E%20%3CFONT%20color%3D%22%238b0000%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E%22Export%20-%20%22%3C%2FFONT%3E%20%3CFONT%20color%3D%22%23a9a9a9%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E%2B%3C%2FFONT%3E%20%3CFONT%20color%3D%22%23ff4500%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E%24term%3C%2FFONT%3E%3CFONT%20color%3D%22%23a9a9a9%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E.%3C%2FFONT%3E%3CFONT%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3EName%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20color%3D%22%230000ff%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3ENew-ComplianceSearch%3C%2FFONT%3E%20%3CFONT%20color%3D%22%23000080%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E-ExchangeLocation%3C%2FFONT%3E%20%3CFONT%20color%3D%22%23ff4500%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E%24user365%3C%2FFONT%3E%3CFONT%20color%3D%22%23a9a9a9%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E.%3C%2FFONT%3E%3CFONT%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3EWindowsLiveID%20%3C%2FFONT%3E%3CFONT%20color%3D%22%23000080%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E-Name%3C%2FFONT%3E%20%3CFONT%20color%3D%22%23ff4500%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E%24SearchName%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%23%20Start%20Compliance%20Search%20and%20wait%20to%20complete%3C%2FP%3E%0A%3CP%3E%3CFONT%20color%3D%22%230000ff%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3EStart-ComplianceSearch%3C%2FFONT%3E%20%3CFONT%20color%3D%22%23ff4500%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E%24SearchName%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3Edo%3C%2FP%3E%0A%3CP%3E%7B%3C%2FP%3E%0A%3CP%3E%3CFONT%20color%3D%22%230000ff%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3EStart-Sleep%3C%2FFONT%3E%20%3CFONT%20color%3D%22%23000080%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E-s%3C%2FFONT%3E%20%3CFONT%20color%3D%22%23800080%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E5%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20color%3D%22%23ff4500%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E%24complianceSearch%3C%2FFONT%3E%20%3CFONT%20color%3D%22%23a9a9a9%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E%3D%3C%2FFONT%3E%20%3CFONT%20color%3D%22%230000ff%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3EGet-ComplianceSearch%3C%2FFONT%3E%20%3CFONT%20color%3D%22%23ff4500%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E%24SearchName%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%7D%3C%2FP%3E%0A%3CP%3E%3CFONT%20color%3D%22%2300008b%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3Ewhile%3C%2FFONT%3E%3CFONT%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E%20(%3C%2FFONT%3E%3CFONT%20color%3D%22%23ff4500%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E%24complianceSearch%3C%2FFONT%3E%3CFONT%20color%3D%22%23a9a9a9%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E.%3C%2FFONT%3E%3CFONT%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3EStatus%20%3C%2FFONT%3E%3CFONT%20color%3D%22%23a9a9a9%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E-ne%3C%2FFONT%3E%20%3CFONT%20color%3D%22%238b0000%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E'Completed'%3C%2FFONT%3E%3CFONT%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E)%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%23%20Create%20Compliance%20Search%20in%20exportable%20format%3C%2FP%3E%0A%3CP%3E%3CFONT%20color%3D%22%230000ff%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3ENew-ComplianceSearchAction%3C%2FFONT%3E%20%3CFONT%20color%3D%22%23000080%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E-SearchName%3C%2FFONT%3E%20%3CFONT%20color%3D%22%23ff4500%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E%24SearchName%3C%2FFONT%3E%20%3CFONT%20color%3D%22%23000080%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E-EnableDedupe%3C%2FFONT%3E%20%3CFONT%20color%3D%22%23ff4500%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E%24true%3C%2FFONT%3E%20%3CFONT%20color%3D%22%23000080%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E-Export%3C%2FFONT%3E%20%3CFONT%20color%3D%22%23000080%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E-Format%3C%2FFONT%3E%20%3CFONT%20color%3D%22%238a2be2%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3EFxStream%3C%2FFONT%3E%20%3CFONT%20color%3D%22%23000080%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E-ArchiveFormat%3C%2FFONT%3E%20%3CFONT%20color%3D%22%238a2be2%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3EPerUserPST%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%23Wait%20for%20Export%20to%20complete%3C%2FP%3E%0A%3CP%3Edo%3C%2FP%3E%0A%3CP%3E%7B%3C%2FP%3E%0A%3CP%3E%3CFONT%20color%3D%22%230000ff%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3EStart-Sleep%3C%2FFONT%3E%20%3CFONT%20color%3D%22%23000080%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E-s%3C%2FFONT%3E%20%3CFONT%20color%3D%22%23800080%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E5%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20color%3D%22%23ff4500%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E%24complete%3C%2FFONT%3E%20%3CFONT%20color%3D%22%23a9a9a9%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E%3D%3C%2FFONT%3E%20%3CFONT%20color%3D%22%230000ff%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3EGet-ComplianceSearchAction%3C%2FFONT%3E%20%3CFONT%20color%3D%22%23000080%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E-Identity%3C%2FFONT%3E%20%3CFONT%20color%3D%22%23ff4500%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E%24ExportName%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%7D%3C%2FP%3E%0A%3CP%3E%3CLI-WRAPPER%3E%3C%2FLI-WRAPPER%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20color%3D%22%2300008b%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3Ewhile%3C%2FFONT%3E%3CFONT%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E%20(%3C%2FFONT%3E%3CFONT%20color%3D%22%23ff4500%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E%24complete%3C%2FFONT%3E%3CFONT%20color%3D%22%23a9a9a9%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E.%3C%2FFONT%3E%3CFONT%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3EStatus%20%3C%2FFONT%3E%3CFONT%20color%3D%22%23a9a9a9%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E-ne%3C%2FFONT%3E%20%3CFONT%20color%3D%22%238b0000%22%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E'Completed'%3C%2FFONT%3E%3CFONT%20face%3D%22Lucida%20Console%22%20size%3D%221%22%3E)%3C%2FFONT%3E%20%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-141405%22%20slang%3D%22en-US%22%3ERe%3A%20Export%20to%20PST%20via%20Powershell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-141405%22%20slang%3D%22en-US%22%3EIs%20it%20possible%20for%20me%20to%20create%20a%20PS%20script%20that%20downloads%20PST's%20through%20e%20discovery%3F%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-141401%22%20slang%3D%22en-US%22%3ERe%3A%20Export%20to%20PST%20via%20Powershell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-141401%22%20slang%3D%22en-US%22%3E%3CP%3EThrough%20E-Discovery%20yes%2C%20not%20through%20regular%20Exchange%20Online.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThere%20are%20third-party%20tools%20out%20there%20that%20have%20created%20tools%20for%20this.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-141022%22%20slang%3D%22en-US%22%3ERe%3A%20Export%20to%20PST%20via%20Powershell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-141022%22%20slang%3D%22en-US%22%3EHi%20Vasil%3CBR%20%2F%3E%3CBR%20%2F%3ESo%20you%20are%20saying%20there%20is%20no%20way%20to%20export%20a%20user's%20mailbox%20through%20PowerShell%3F%3CBR%20%2F%3E%3CBR%20%2F%3EKind%20regards%3CBR%20%2F%3EThijs%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-95030%22%20slang%3D%22en-US%22%3ERe%3A%20Export%20to%20PST%20via%20Powershell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-95030%22%20slang%3D%22en-US%22%3E%3CP%3ENo%20way%20to%20do%20it%20without%20going%20to%20the%20SCC%20and%20initializing%20the%20download%20via%20the%20click-one%20app%2C%20sorry.%26nbsp%3BPerhaps%20you%20can%20automate%20it%20via%20AzCopy%20or%20some%20other%20tool%20that%20takes%20container%2Ftoken%20as%20input%20-%20you%20can%20get%20those%20via%20the%20Result%20property%20of%20Get-ComplianceSearchAction.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAs%20for%20the%20cmdlet%2C%20make%20sure%20you%20also%20use%20the%20-Format%20parameter!%3C%2FP%3E%3CBLOCKQUOTE%3E%3CHR%20%2F%3E%3CP%3EThe%20Format%20parameter%20specifies%20the%20format%20of%20the%20search%20results%20when%20you%20use%20the%20Export%20switch.%20Valid%20values%20are%3A%3C%2FP%3E%3CP%3E%3CBR%20%2F%3EFxStream%26nbsp%3B%26nbsp%3B%20Export%20to%20PST%20files.%20This%20is%20the%20only%20option%20that's%20available%20when%20you%20export%20search%20results%20from%20the%20Security%20%26amp%3B%20Compliance%20Center.%3C%2FP%3E%3CP%3E%3CBR%20%2F%3EMime%26nbsp%3B%26nbsp%3B%20Export%20to%20.eml%20messsage%20files.%20This%20the%20default%20value%20when%20you%20use%20cmdlets%20to%20export%20the%20search%20results.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CHR%20%2F%3E%3C%2FBLOCKQUOTE%3E%3CP%3EIt's%20most%20likely%20what%20causes%20the%20issue%20in%20your%20case.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-445127%22%20slang%3D%22en-US%22%3ERe%3A%20Export%20to%20PST%20via%20Powershell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-445127%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F94211%22%20target%3D%22_blank%22%3E%40Edgar%20Guerrero%3C%2FA%3E%26nbsp%3BSure%2C%20I%20think%20I%20sanitized%20it%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CDIV%3E%3CDIV%3E%3CSPAN%3E%23region%20Connect%20to%20all%20the%20things%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%23Test%20O365%20Connection%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EIf%3C%2FSPAN%3E%3CSPAN%3E(%3C%2FSPAN%3E%3CSPAN%3E%24Null%3C%2FSPAN%3E%20%3CSPAN%3E-eq%3C%2FSPAN%3E%20%3CSPAN%3E%24O365Cred%3C%2FSPAN%3E%3CSPAN%3E)%7B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%24O365Cred%3C%2FSPAN%3E%20%3CSPAN%3E%3D%3C%2FSPAN%3E%3CSPAN%3E%20%24Host%3C%2FSPAN%3E%3CSPAN%3E.ui.PromptForCredential%3C%2FSPAN%3E%3CSPAN%3E(%3C%2FSPAN%3E%3CSPAN%3E%22%22%3C%2FSPAN%3E%3CSPAN%3E%2C%3C%2FSPAN%3E%3CSPAN%3E%22Enter%20your%20OFFICE%20365%20admin%20creds%22%3C%2FSPAN%3E%3CSPAN%3E%2C%3C%2FSPAN%3E%3CSPAN%3E%22ENTER%20YOUR%20ACCOUNT%20NAME%20HERE%22%3C%2FSPAN%3E%3CSPAN%3E%2C%3C%2FSPAN%3E%3CSPAN%3E%22%22%3C%2FSPAN%3E%3CSPAN%3E)%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%7D%3C%2FSPAN%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3ETry%3C%2FSPAN%3E%3CSPAN%3E%7B%3C%2FSPAN%3E%3CSPAN%3EGet-O365Mailbox%3C%2FSPAN%3E%3CSPAN%3E%20aguerot%20%3C%2FSPAN%3E%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EErrorAction%20Stop%20%3C%2FSPAN%3E%3CSPAN%3E%26gt%3B%3C%2FSPAN%3E%20%3CSPAN%3E%24Null%3C%2FSPAN%3E%3CSPAN%3E%7D%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3ECatch%3C%2FSPAN%3E%3CSPAN%3E%7B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%24O365Session%3C%2FSPAN%3E%20%3CSPAN%3E%3D%3C%2FSPAN%3E%20%3CSPAN%3ENew-PSSession%3C%2FSPAN%3E%20%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EConfigurationName%20Microsoft.Exchange%20%3C%2FSPAN%3E%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EConnectionUri%20https%3A%3C%2FSPAN%3E%3CSPAN%3E%2F%2F%3C%2FSPAN%3E%3CSPAN%3Eoutlook.office365.com%3C%2FSPAN%3E%3CSPAN%3E%2F%3C%2FSPAN%3E%3CSPAN%3Epowershell%3C%2FSPAN%3E%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3Eliveid%3C%2FSPAN%3E%3CSPAN%3E%2F%3C%2FSPAN%3E%20%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3ECredential%20%3C%2FSPAN%3E%3CSPAN%3E%24O365Cred%3C%2FSPAN%3E%20%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EAuthentication%20Basic%20%3C%2FSPAN%3E%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EAllowRedirection%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EImport-PSSession%3C%2FSPAN%3E%20%3CSPAN%3E%24O365Session%3C%2FSPAN%3E%3CSPAN%3E%20%E2%80%93Prefix%20o365%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%7D%3C%2FSPAN%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3ETry%3C%2FSPAN%3E%3CSPAN%3E%7B%3C%2FSPAN%3E%3CSPAN%3EGet-MsolUser%3C%2FSPAN%3E%20%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EUserPrincipalName%20ENTER%20TEST%20USER%20HERE%20%3C%2FSPAN%3E%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EErrorAction%20Stop%20%3C%2FSPAN%3E%3CSPAN%3E%26gt%3B%3C%2FSPAN%3E%20%3CSPAN%3E%24Null%3C%2FSPAN%3E%3CSPAN%3E%7D%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3ECatch%3C%2FSPAN%3E%3CSPAN%3E%7B%3C%2FSPAN%3E%3CSPAN%3EConnect-MsolService%3C%2FSPAN%3E%20%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3ECredential%20%3C%2FSPAN%3E%3CSPAN%3E%24O365Cred%3C%2FSPAN%3E%3CSPAN%3E%7D%3C%2FSPAN%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3ETry%3C%2FSPAN%3E%3CSPAN%3E%7B%3C%2FSPAN%3E%3CSPAN%3EGet-ComplianceSearch%3C%2FSPAN%3E%20%3CSPAN%3E%26gt%3B%3C%2FSPAN%3E%20%3CSPAN%3E%24Null%3C%2FSPAN%3E%3CSPAN%3E%7D%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3ECatch%3C%2FSPAN%3E%3CSPAN%3E%7B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%23Get%20login%20credentials%20%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%24Session%3C%2FSPAN%3E%20%3CSPAN%3E%3D%3C%2FSPAN%3E%20%3CSPAN%3ENew-PSSession%3C%2FSPAN%3E%20%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EConfigurationName%20Microsoft.Exchange%20%3C%2FSPAN%3E%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EConnectionUri%20https%3A%3C%2FSPAN%3E%3CSPAN%3E%2F%2F%3C%2FSPAN%3E%3CSPAN%3Eps.compliance.protection.outlook.com%3C%2FSPAN%3E%3CSPAN%3E%2F%3C%2FSPAN%3E%3CSPAN%3Epowershell%3C%2FSPAN%3E%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3Eliveid%20%3C%2FSPAN%3E%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3ECredential%20%3C%2FSPAN%3E%3CSPAN%3E%24O365Cred%3C%2FSPAN%3E%20%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EAuthentication%20Basic%20%3C%2FSPAN%3E%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EAllowRedirection%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EImport-PSSession%3C%2FSPAN%3E%20%3CSPAN%3E%24Session%3C%2FSPAN%3E%20%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EAllowClobber%20%3C%2FSPAN%3E%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EDisableNameChecking%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%7D%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%23endregion%3C%2FSPAN%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3E%23Get%20User%20Info%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%24User%3C%2FSPAN%3E%20%3CSPAN%3E%3D%3C%2FSPAN%3E%20%3CSPAN%3ERead-host%3C%2FSPAN%3E%20%3CSPAN%3E%22Enter%20user%20name%22%3C%2FSPAN%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3E%24Logfile%3C%2FSPAN%3E%20%3CSPAN%3E%3D%3C%2FSPAN%3E%20%3CSPAN%3E%22PATH%20TO%20LOG%20FILE%5C%3C%2FSPAN%3E%3CSPAN%3E%24User%3C%2FSPAN%3E%3CSPAN%3E.txt%22%3C%2FSPAN%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3EFunction%3C%2FSPAN%3E%20%3CSPAN%3ELogWrite%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%7B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EParam%3C%2FSPAN%3E%3CSPAN%3E%20(%5B%3C%2FSPAN%3E%3CSPAN%3Estring%3C%2FSPAN%3E%3CSPAN%3E%5D%3C%2FSPAN%3E%3CSPAN%3E%24logstring%3C%2FSPAN%3E%3CSPAN%3E)%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EWrite-Host%3C%2FSPAN%3E%20%3CSPAN%3E%24LogString%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EAdd-content%3C%2FSPAN%3E%20%3CSPAN%3E%24Logfile%3C%2FSPAN%3E%20%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3Evalue%20%3C%2FSPAN%3E%3CSPAN%3E%24logstring%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%7D%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%24Date%3C%2FSPAN%3E%20%3CSPAN%3E%3D%3C%2FSPAN%3E%20%3CSPAN%3EGet-Date%3C%2FSPAN%3E%20%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EFormat%20%3C%2FSPAN%3E%3CSPAN%3E%22MM%2Fdd%2Fyyyy%22%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3ELogWrite%20%3C%2FSPAN%3E%3CSPAN%3E%24Date%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3ELogWrite%20%3C%2FSPAN%3E%3CSPAN%3E%22%20%22%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3ELogWrite%20%3C%2FSPAN%3E%3CSPAN%3E%22Username%3A%20%3C%2FSPAN%3E%3CSPAN%3E%24User%3C%2FSPAN%3E%3CSPAN%3E%22%3C%2FSPAN%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3E%23Begin%20Compliance%20Search%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%24UPN%3C%2FSPAN%3E%20%3CSPAN%3E%3D%3C%2FSPAN%3E%20%3CSPAN%3EGet-ADUser%3C%2FSPAN%3E%20%3CSPAN%3E%24User%3C%2FSPAN%3E%20%3CSPAN%3E%7C%3C%2FSPAN%3E%20%3CSPAN%3EForEach-Object%3C%2FSPAN%3E%3CSPAN%3E%7B%24_%3C%2FSPAN%3E%3CSPAN%3E.UserPrincipalName%3C%2FSPAN%3E%3CSPAN%3E%7D%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%24SearchName%3C%2FSPAN%3E%20%3CSPAN%3E%3D%3C%2FSPAN%3E%20%3CSPAN%3E%24User%3C%2FSPAN%3E%20%3CSPAN%3E%2B%3C%2FSPAN%3E%20%3CSPAN%3E%22_Termed%22%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3ENew-ComplianceSearch%3C%2FSPAN%3E%20%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EName%20%3C%2FSPAN%3E%3CSPAN%3E%24SearchName%3C%2FSPAN%3E%20%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EExchangeLocation%20%3C%2FSPAN%3E%3CSPAN%3E%24UPN%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EStart-ComplianceSearch%3C%2FSPAN%3E%20%3CSPAN%3E%24SearchName%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3ELogwrite%20%3C%2FSPAN%3E%3CSPAN%3E%22%20%22%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3ELogWrite%20%3C%2FSPAN%3E%3CSPAN%3E%22Compliance%20search%20%3C%2FSPAN%3E%3CSPAN%3E%24SearchName%3C%2FSPAN%3E%3CSPAN%3E%20started%22%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EDo%3C%2FSPAN%3E%3CSPAN%3E%7B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%24complianceSearch%3C%2FSPAN%3E%20%3CSPAN%3E%3D%3C%2FSPAN%3E%20%3CSPAN%3EGet-ComplianceSearch%3C%2FSPAN%3E%20%3CSPAN%3E%24SearchName%3C%2FSPAN%3E%20%3CSPAN%3E%7C%3C%2FSPAN%3E%20%3CSPAN%3EForEach-Object%3C%2FSPAN%3E%3CSPAN%3E%7B%24_%3C%2FSPAN%3E%3CSPAN%3E.Status%3C%2FSPAN%3E%3CSPAN%3E%7D%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EWrite-Host%3C%2FSPAN%3E%20%3CSPAN%3E%22Compliance%20Search%20in%20Progress%22%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EStart-Sleep%3C%2FSPAN%3E%20%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3Es%20%3C%2FSPAN%3E%3CSPAN%3E30%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%7D%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EWhile%3C%2FSPAN%3E%3CSPAN%3E%20(%3C%2FSPAN%3E%3CSPAN%3E%24complianceSearch%3C%2FSPAN%3E%20%3CSPAN%3E-ne%3C%2FSPAN%3E%20%3CSPAN%3E'Completed'%3C%2FSPAN%3E%3CSPAN%3E)%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%24Size%3C%2FSPAN%3E%20%3CSPAN%3E%3D%3C%2FSPAN%3E%20%3CSPAN%3EGet-ComplianceSearch%3C%2FSPAN%3E%20%3CSPAN%3E%24SearchName%3C%2FSPAN%3E%20%3CSPAN%3E%7C%3C%2FSPAN%3E%20%3CSPAN%3EForEach-Object%3C%2FSPAN%3E%3CSPAN%3E%7B%24_%3C%2FSPAN%3E%3CSPAN%3E.Size%3C%2FSPAN%3E%3CSPAN%3E%7D%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%24Size%3C%2FSPAN%3E%20%3CSPAN%3E%3D%3C%2FSPAN%3E%20%3CSPAN%3E%24Size%3C%2FSPAN%3E%20%3CSPAN%3E%2F%3C%2FSPAN%3E%20%3CSPAN%3E1048576%3C%2FSPAN%3E%20%3CSPAN%3E%7C%3C%2FSPAN%3E%20%3CSPAN%3EOut-String%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%24Size%3C%2FSPAN%3E%20%3CSPAN%3E%3D%3C%2FSPAN%3E%20%3CSPAN%3E%24Size.SubString%3C%2FSPAN%3E%3CSPAN%3E(%3C%2FSPAN%3E%3CSPAN%3E0%3C%2FSPAN%3E%3CSPAN%3E%2C%3C%2FSPAN%3E%3CSPAN%3E6%3C%2FSPAN%3E%3CSPAN%3E)%3C%2FSPAN%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3E%23%20Create%20Compliance%20Search%20in%20exportable%20format%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3ENew-ComplianceSearchAction%3C%2FSPAN%3E%20%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3ESearchName%20%3C%2FSPAN%3E%3CSPAN%3E%24SearchName%3C%2FSPAN%3E%20%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EEnableDedupe%20%3C%2FSPAN%3E%3CSPAN%3E%24true%3C%2FSPAN%3E%20%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EExport%20%3C%2FSPAN%3E%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EFormat%20FxStream%20%3C%2FSPAN%3E%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EArchiveFormat%20PerUserPST%20%3C%2FSPAN%3E%3CSPAN%3E%26gt%3B%3C%2FSPAN%3E%20%3CSPAN%3E%24Null%3C%2FSPAN%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3E%23Wait%20for%20Export%20to%20complete%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%24ExportName%3C%2FSPAN%3E%20%3CSPAN%3E%3D%3C%2FSPAN%3E%20%3CSPAN%3E%24SearchName%3C%2FSPAN%3E%20%3CSPAN%3E%2B%3C%2FSPAN%3E%20%3CSPAN%3E%22_Export%22%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EStart-Sleep%3C%2FSPAN%3E%20%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3Es%20%3C%2FSPAN%3E%3CSPAN%3E20%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3Edo%3C%2FSPAN%3E%3CSPAN%3E%7B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%24SearchAction%3C%2FSPAN%3E%20%3CSPAN%3E%3D%3C%2FSPAN%3E%20%3CSPAN%3EGet-ComplianceSearchAction%3C%2FSPAN%3E%20%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EIdentity%20%3C%2FSPAN%3E%3CSPAN%3E%24ExportName%3C%2FSPAN%3E%20%3CSPAN%3E%7C%3C%2FSPAN%3E%20%3CSPAN%3ESelect-Object%3C%2FSPAN%3E%3CSPAN%3E%20Status%3C%2FSPAN%3E%3CSPAN%3E%2C%3C%2FSPAN%3E%3CSPAN%3EJobProgress%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%24Status%3C%2FSPAN%3E%20%3CSPAN%3E%3D%3C%2FSPAN%3E%20%3CSPAN%3E%24SearchAction.Status%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%24ExportProgress%3C%2FSPAN%3E%20%3CSPAN%3E%3D%3C%2FSPAN%3E%20%3CSPAN%3E%24SearchAction.JobProgress%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EWrite-Host%3C%2FSPAN%3E%20%3CSPAN%3E%22Export%20in%20progress%2C%20%3C%2FSPAN%3E%3CSPAN%3E%24ExportProgress%3C%2FSPAN%3E%3CSPAN%3E%20complete%22%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EIf%3C%2FSPAN%3E%3CSPAN%3E(%3C%2FSPAN%3E%3CSPAN%3E%24Status%3C%2FSPAN%3E%20%3CSPAN%3E-ne%3C%2FSPAN%3E%20%3CSPAN%3E%22Completed%22%3C%2FSPAN%3E%3CSPAN%3E)%7B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EStart-Sleep%3C%2FSPAN%3E%20%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3Es%20%3C%2FSPAN%3E%3CSPAN%3E60%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%7D%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%7D%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3Ewhile%3C%2FSPAN%3E%3CSPAN%3E%20(%3C%2FSPAN%3E%3CSPAN%3E%24Status%3C%2FSPAN%3E%20%3CSPAN%3E-ne%3C%2FSPAN%3E%20%3CSPAN%3E'Completed'%3C%2FSPAN%3E%3CSPAN%3E)%3C%2FSPAN%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3ELogWrite%20%3C%2FSPAN%3E%3CSPAN%3E%22Compliance%20search%20completed%22%3C%2FSPAN%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3E%23Taken%20from%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FOffice-365%2FExport-to-PST-via-Powershell%2Fm-p%2F193934%2Fhighlight%2Ffalse%23M13088%22%20target%3D%22_blank%22%20rel%3D%22noopener%22%3Ehttps%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FOffice-365%2FExport-to-PST-via-Powershell%2Fm-p%2F193934%2Fhighlight%2Ffalse%23M13088%3C%2FA%3E%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%24exportlocation%3C%2FSPAN%3E%20%3CSPAN%3E%3D%3C%2FSPAN%3E%20%3CSPAN%3E%22C%3A%5Cpst%22%3C%2FSPAN%3E%20%3CSPAN%3E%23enter%20the%20path%20to%20your%20export%20here%20!NO%20TRAILING%20BACKSLASH!%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%24exportexe%3C%2FSPAN%3E%20%3CSPAN%3E%3D%3C%2FSPAN%3E%20%3CSPAN%3E%22%5CUnifiedExportTool%5Cmicrosoft.office.client.discovery.unifiedexporttool.exe%22%3C%2FSPAN%3E%20%3CSPAN%3E%23path%20to%20your%20microsoft.office.client.discovery.unifiedexporttool.exe%20file.%20Usually%20found%20somewhere%20in%20ForEach-ObjectLOCALAPPDATAForEach-Object%5CApps%5C2.0%5C%3C%2FSPAN%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3E%23%20Gather%20the%20URL%20and%20Token%20from%20the%20export%20in%20order%20to%20start%20the%20download%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%23We%20only%20need%20the%20ContainerURL%20and%20SAS%20Token%20but%20I%20parsed%20some%20other%20fields%20as%20well%20while%20working%20with%20AzCopy%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%23The%20Container%20URL%20and%20Token%20in%20the%20following%20template%20has%20been%20altered%20to%20protect%20the%20innocent%3A%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%24exporttemplate%3C%2FSPAN%3E%20%3CSPAN%3E%3D%3C%2FSPAN%3E%20%3CSPAN%3E%40'%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EContainer%20url%3A%20%7BContainerURL*%3A%3CA%20href%3D%22https%3A%2F%2Fxicnediscnam.blob.core.windows.net%2Fda3fecb0-4ed4-447e-0315-08d5adad8a5a%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fxicnediscnam.blob.core.windows.net%2Fda3fecb0-4ed4-447e-0315-08d5adad8a5a%3C%2FA%3E%7D%3B%20SAS%20token%3A%20%7BSASToken%3A%3Fsv%3D2014-02-14%26amp%3Bsr%3Dc%26amp%3Bsi%3DeDiscoveryBlobPolicy9ForEach-Object7C0%26amp%3Bsig%3DRACMSyH6Cf0k4EP2wZSoAa0QrhKaV38Oa9ciHv5Y8MkForEach-Object3D%7D%3B%20Scenario%3A%20General%3B%20Scope%3A%20BothIndexedAndUnindexedItems%3B%20Scope%20details%3A%20AllUnindexed%3B%20Max%20unindexed%20size%3A%200%3B%20File%20type%20exclusions%20for%20unindexed%3A%20%3CNULL%3E%3B%20Total%20sources%3A%202%3B%20Exchange%20item%20format%3A%20Msg%3B%20Exchange%20archive%20format%3A%20IndividualMessage%3B%20SharePoint%20archive%20format%3A%20SingleZip%3B%20Include%20SharePoint%20versions%3A%20True%3B%20Enable%20dedupe%3A%20EnableDedupe%3ATrue%3B%20Reference%20action%3A%20%22%3CNULL%3E%22%3B%20Region%3A%20%3B%20Started%20sources%3A%20StartedSources%3A3%3B%20Succeeded%20sources%3A%20SucceededSources%3A1%3B%20Failed%20sources%3A%200%3B%20Total%20estimated%20bytes%3A%2012%2C791%2C334%2C934%3B%20Total%20estimated%20items%3A%20143%2C729%3B%20Total%20transferred%20bytes%3A%20%7BTotalTransferredBytes%3A7%2C706%2C378%2C435%7D%3B%20Total%20transferred%20items%3A%20%7BTotalTransferredItems%3A71%2C412%7D%3B%20Progress%3A%20%7BProgress%3A49.69%20ForEach-Object%7D%3B%20Completed%20time%3A%20%3B%20Duration%3A%2000%3A50%3A43.9321895%3B%20Export%20status%3A%20%7BExportStatus%3ADistributionCompleted%7D%3C%2FNULL%3E%3C%2FNULL%3E%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EContainer%20url%3A%20%7BContainerURL*%3A%3CA%20href%3D%22https%3A%2F%2Fzgrbediscnam.blob.core.windows.net%2F5c21f7c7-42a2-4e24-9e69-08d5acf316f5%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fzgrbediscnam.blob.core.windows.net%2F5c21f7c7-42a2-4e24-9e69-08d5acf316f5%3C%2FA%3E%7D%3B%20SAS%20token%3A%20%7BSASToken%3A%3Fsv%3D2014-02-14%26amp%3Bsr%3Dc%26amp%3Bsi%3DeDiscoveryBlobPolicy9ForEach-Object7C0%26amp%3Bsig%3DF6ycaX5eWcRBCS1Z5nfoTKJWTrHkAciqbYRP5ForEach-Object2FhsUOoForEach-Object3D%7D%3B%20Scenario%3A%20General%3B%20Scope%3A%20BothIndexedAndUnindexedItems%3B%20Scope%20details%3A%20AllUnindexed%3B%20Max%20unindexed%20size%3A%200%3B%20File%20type%20exclusions%20for%20unindexed%3A%20%3CNULL%3E%3B%20Total%20sources%3A%201%3B%20Exchange%20item%20format%3A%20FxStream%3B%20Exchange%20archive%20format%3A%20PerUserPst%3B%20SharePoint%20archive%20format%3A%20IndividualMessage%3B%20Include%20SharePoint%20versions%3A%20True%3B%20Enable%20dedupe%3A%20True%3B%20Reference%20action%3A%20%22%3CNULL%3E%22%3B%20Region%3A%20%3B%20Started%20sources%3A%202%3B%20Succeeded%20sources%3A%202%3B%20Failed%20sources%3A%200%3B%20Total%20estimated%20bytes%3A%2069%2C952%2C559%2C461%3B%20Total%20estimated%20items%3A%20107%2C707%3B%20Total%20transferred%20bytes%3A%20%7BTotalTransferredBytes%3A70%2C847%2C990%2C489%7D%3B%20Total%20transferred%20items%3A%20%7BTotalTransferredItems%3A100%2C808%7D%3B%20Progress%3A%20%7BProgress%3A93.59%20ForEach-Object%7D%3B%20Completed%20time%3A%204%2F27%2F2018%2011%3A45%3A46%20PM%3B%20Duration%3A%2004%3A31%3A21.1593737%3B%20Export%20status%3A%20%7BExportStatus%3ACompleted%7D%3C%2FNULL%3E%3C%2FNULL%3E%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E'%40%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%24exportdetails%3C%2FSPAN%3E%20%3CSPAN%3E%3D%3C%2FSPAN%3E%20%3CSPAN%3EGet-ComplianceSearchAction%3C%2FSPAN%3E%20%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EIdentity%20%3C%2FSPAN%3E%3CSPAN%3E%24exportname%3C%2FSPAN%3E%20%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EIncludeCredential%20%3C%2FSPAN%3E%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EDetails%20%3C%2FSPAN%3E%3CSPAN%3E%7C%3C%2FSPAN%3E%20%3CSPAN%3ESelect-Object%3C%2FSPAN%3E%20%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EExpandProperty%20Results%20%3C%2FSPAN%3E%3CSPAN%3E%7C%3C%2FSPAN%3E%20%3CSPAN%3EConvertFrom-String%3C%2FSPAN%3E%20%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3ETemplateContent%20%3C%2FSPAN%3E%3CSPAN%3E%24exporttemplate%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%24exportdetails%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%24exportcontainerurl%3C%2FSPAN%3E%20%3CSPAN%3E%3D%3C%2FSPAN%3E%20%3CSPAN%3E%24exportdetails.ContainerURL%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%24exportsastoken%3C%2FSPAN%3E%20%3CSPAN%3E%3D%3C%2FSPAN%3E%20%3CSPAN%3E%24exportdetails.SASToken%3C%2FSPAN%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3E%23%20Download%20the%20exported%20files%20from%20Office%20365%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EWrite-Host%3C%2FSPAN%3E%20%3CSPAN%3E%22Compliance%20Search%20Size%3A%22%3C%2FSPAN%3E%20%3CSPAN%3E%24Size%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3ELogWrite%20%3C%2FSPAN%3E%3CSPAN%3E%22Initiating%20download%22%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3ELogWrite%20%3C%2FSPAN%3E%3CSPAN%3E%22Saving%20export%20to%3A%20%3C%2FSPAN%3E%3CSPAN%3E%24exportlocation%3C%2FSPAN%3E%3CSPAN%3E%22%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%24arguments%3C%2FSPAN%3E%20%3CSPAN%3E%3D%3C%2FSPAN%3E%20%3CSPAN%3E%22-name%20%3C%2FSPAN%3E%3CSPAN%3E%22%22%3C%2FSPAN%3E%3CSPAN%3E%24searchname%3C%2FSPAN%3E%3CSPAN%3E%22%22%3C%2FSPAN%3E%3CSPAN%3E%22%3C%2FSPAN%3E%3CSPAN%3E%2C%3C%2FSPAN%3E%3CSPAN%3E%22-source%20%3C%2FSPAN%3E%3CSPAN%3E%22%22%3C%2FSPAN%3E%3CSPAN%3E%24exportcontainerurl%3C%2FSPAN%3E%3CSPAN%3E%22%22%3C%2FSPAN%3E%3CSPAN%3E%22%3C%2FSPAN%3E%3CSPAN%3E%2C%3C%2FSPAN%3E%3CSPAN%3E%22-key%20%3C%2FSPAN%3E%3CSPAN%3E%22%22%3C%2FSPAN%3E%3CSPAN%3E%24exportsastoken%3C%2FSPAN%3E%3CSPAN%3E%22%22%3C%2FSPAN%3E%3CSPAN%3E%22%3C%2FSPAN%3E%3CSPAN%3E%2C%3C%2FSPAN%3E%3CSPAN%3E%22-dest%20%3C%2FSPAN%3E%3CSPAN%3E%22%22%3C%2FSPAN%3E%3CSPAN%3E%24exportlocation%3C%2FSPAN%3E%3CSPAN%3E%22%22%3C%2FSPAN%3E%3CSPAN%3E%22%3C%2FSPAN%3E%3CSPAN%3E%2C%3C%2FSPAN%3E%3CSPAN%3E%22-trace%20true%22%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EStart-Process%3C%2FSPAN%3E%20%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EFilePath%20%3C%2FSPAN%3E%3CSPAN%3E%22%3C%2FSPAN%3E%3CSPAN%3E%24exportexe%3C%2FSPAN%3E%3CSPAN%3E%22%3C%2FSPAN%3E%20%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EArgumentList%20%3C%2FSPAN%3E%3CSPAN%3E%24arguments%3C%2FSPAN%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3E%23Do%20while%20microsoft.office.client.discovery.unifiedexporttool.exe%20running%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%24started%3C%2FSPAN%3E%20%3CSPAN%3E%3D%3C%2FSPAN%3E%20%3CSPAN%3E%24false%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EDo%3C%2FSPAN%3E%3CSPAN%3E%20%7B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%24status%3C%2FSPAN%3E%20%3CSPAN%3E%3D%3C%2FSPAN%3E%20%3CSPAN%3EGet-Process%3C%2FSPAN%3E%3CSPAN%3E%20microsoft.office.client.discovery.unifiedexporttool%20%3C%2FSPAN%3E%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EErrorAction%20SilentlyContinue%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EIf%3C%2FSPAN%3E%3CSPAN%3E%20(%3C%2FSPAN%3E%3CSPAN%3E!%3C%2FSPAN%3E%3CSPAN%3E(%3C%2FSPAN%3E%3CSPAN%3E%24status%3C%2FSPAN%3E%3CSPAN%3E))%20%7B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EWrite-Host%3C%2FSPAN%3E%20%3CSPAN%3E'Waiting%20for%20process%20to%20start'%3C%2FSPAN%3E%3CSPAN%3E%20%3B%20%3C%2FSPAN%3E%3CSPAN%3EStart-Sleep%3C%2FSPAN%3E%20%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3ESeconds%20%3C%2FSPAN%3E%3CSPAN%3E5%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%7D%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EElse%3C%2FSPAN%3E%3CSPAN%3E%20%7B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EWrite-Host%3C%2FSPAN%3E%20%3CSPAN%3E'Process%20has%20started'%3C%2FSPAN%3E%3CSPAN%3E%20%3B%20%3C%2FSPAN%3E%3CSPAN%3E%24started%3C%2FSPAN%3E%20%3CSPAN%3E%3D%3C%2FSPAN%3E%20%3CSPAN%3E%24true%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%7D%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%7D%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EUntil%3C%2FSPAN%3E%3CSPAN%3E%20(%20%3C%2FSPAN%3E%3CSPAN%3E%24started%3C%2FSPAN%3E%3CSPAN%3E%20)%3C%2FSPAN%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3EDo%3C%2FSPAN%3E%3CSPAN%3E%7B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%24Finished%3C%2FSPAN%3E%20%3CSPAN%3E%3D%3C%2FSPAN%3E%20%3CSPAN%3E%24False%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EWrite-host%3C%2FSPAN%3E%20%3CSPAN%3E%22Sleeping%20300%20seconds%22%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EStart-Sleep%3C%2FSPAN%3E%20%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3Es%20%3C%2FSPAN%3E%3CSPAN%3E300%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%24DownloadSize%3C%2FSPAN%3E%20%3CSPAN%3E%3D%3C%2FSPAN%3E%20%3CSPAN%3EGet-Childitem%3C%2FSPAN%3E%20%3CSPAN%3E%22C%3A%5Cpst%22%3C%2FSPAN%3E%20%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3Erecurse%20%3C%2FSPAN%3E%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3Einclude%20%3C%2FSPAN%3E%3CSPAN%3E*%3C%2FSPAN%3E%3CSPAN%3E.pst%20%3C%2FSPAN%3E%3CSPAN%3E%7C%3C%2FSPAN%3E%20%3CSPAN%3EForEach-Object%3C%2FSPAN%3E%3CSPAN%3E%7B%24_%3C%2FSPAN%3E%3CSPAN%3E.Length%3C%2FSPAN%3E%3CSPAN%3E%7D%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%24DownloadSize%3C%2FSPAN%3E%20%3CSPAN%3E%3D%3C%2FSPAN%3E%20%3CSPAN%3E%24DownloadSize%3C%2FSPAN%3E%20%3CSPAN%3E%2F%3C%2FSPAN%3E%20%3CSPAN%3E1048576%3C%2FSPAN%3E%20%3CSPAN%3E%7C%3C%2FSPAN%3E%20%3CSPAN%3EOut-String%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%24DownloadSize%3C%2FSPAN%3E%20%3CSPAN%3E%3D%3C%2FSPAN%3E%20%3CSPAN%3E%24DownloadSize.SubString%3C%2FSPAN%3E%3CSPAN%3E(%3C%2FSPAN%3E%3CSPAN%3E0%3C%2FSPAN%3E%3CSPAN%3E%2C%3C%2FSPAN%3E%3CSPAN%3E6%3C%2FSPAN%3E%3CSPAN%3E)%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EWrite-Host%3C%2FSPAN%3E%20%3CSPAN%3E%22%20%22%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EWrite-Host%3C%2FSPAN%3E%20%3CSPAN%3E%22Compliance%20Search%20Size%3A%22%3C%2FSPAN%3E%20%3CSPAN%3E%24Size%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EWrite-Host%3C%2FSPAN%3E%20%3CSPAN%3E%22Downloaded%20Size%3A%22%3C%2FSPAN%3E%20%3CSPAN%3E%24DownloadSize%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EWrite-Host%3C%2FSPAN%3E%20%3CSPAN%3E%22%20%22%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26lt%3B%23%23%20Commenting%20this%20out%20to%20test%20performance%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%24ProcessesFound%20%3D%20Get-Process%20%7C%20%3F%20%7B%24_.Name%20-like%20%22*unifiedexporttool*%22%7D%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EWrite-Host%20%22Process%20still%20running%22%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EIf%20(%24ProcessesFound)%20%7B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%24Progress%20%3D%20get-ComplianceSearchAction%20-Identity%20%24exportname%20-IncludeCredential%20-Details%20%7C%20Select-Object%20-ExpandProperty%20Results%20%7C%20ConvertFrom-String%20-TemplateContent%20%24exporttemplate%20%7C%20ForEach-Object%7B%24_.Progress%7D%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EWrite-Host%20%22Export%20still%20downloading%2C%20progress%20is%20%24Progress%2C%20waiting%20300%20seconds%22%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EStart-Sleep%20-s%20300%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%7D%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%23%26gt%3B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EIf%3C%2FSPAN%3E%3CSPAN%3E(%3C%2FSPAN%3E%3CSPAN%3E%24DownloadSize%3C%2FSPAN%3E%20%3CSPAN%3E-ge%3C%2FSPAN%3E%20%3CSPAN%3E%24Size%3C%2FSPAN%3E%3CSPAN%3E)%7B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%24status%3C%2FSPAN%3E%20%3CSPAN%3E%3D%3C%2FSPAN%3E%20%3CSPAN%3EGet-Process%3C%2FSPAN%3E%3CSPAN%3E%20microsoft.office.client.discovery.unifiedexporttool%20%3C%2FSPAN%3E%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EErrorAction%20SilentlyContinue%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EIf%3C%2FSPAN%3E%3CSPAN%3E%20(%3C%2FSPAN%3E%3CSPAN%3E!%3C%2FSPAN%3E%3CSPAN%3E(%3C%2FSPAN%3E%3CSPAN%3E%24status%3C%2FSPAN%3E%3CSPAN%3E))%20%7B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EWrite-Host%3C%2FSPAN%3E%20%3CSPAN%3E%22Download%20has%20finished%22%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%24Finished%3C%2FSPAN%3E%20%3CSPAN%3E%3D%3C%2FSPAN%3E%20%3CSPAN%3E%24True%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%7D%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%7D%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%7D%3C%2FSPAN%3E%3CSPAN%3EUntil%3C%2FSPAN%3E%3CSPAN%3E%20(%3C%2FSPAN%3E%3CSPAN%3E%24Finished%3C%2FSPAN%3E%20%3CSPAN%3E-eq%3C%2FSPAN%3E%20%3CSPAN%3E%24True%3C%2FSPAN%3E%3CSPAN%3E)%3C%2FSPAN%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3E%24DownloadSize%3C%2FSPAN%3E%20%3CSPAN%3E%3D%3C%2FSPAN%3E%20%3CSPAN%3EGet-Childitem%3C%2FSPAN%3E%20%3CSPAN%3E%22C%3A%5Cpst%22%3C%2FSPAN%3E%20%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3Erecurse%20%3C%2FSPAN%3E%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3Einclude%20%3C%2FSPAN%3E%3CSPAN%3E*%3C%2FSPAN%3E%3CSPAN%3E.pst%20%3C%2FSPAN%3E%3CSPAN%3E%7C%3C%2FSPAN%3E%20%3CSPAN%3EForEach-Object%3C%2FSPAN%3E%3CSPAN%3E%7B%24_%3C%2FSPAN%3E%3CSPAN%3E.Length%3C%2FSPAN%3E%3CSPAN%3E%7D%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%24DownloadSize%3C%2FSPAN%3E%20%3CSPAN%3E%3D%3C%2FSPAN%3E%20%3CSPAN%3E%24DownloadSize%3C%2FSPAN%3E%20%3CSPAN%3E%2F%3C%2FSPAN%3E%20%3CSPAN%3E1048576%3C%2FSPAN%3E%20%3CSPAN%3E%7C%3C%2FSPAN%3E%20%3CSPAN%3EOut-String%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%24DownloadSize%3C%2FSPAN%3E%20%3CSPAN%3E%3D%3C%2FSPAN%3E%20%3CSPAN%3E%24DownloadSize.SubString%3C%2FSPAN%3E%3CSPAN%3E(%3C%2FSPAN%3E%3CSPAN%3E0%3C%2FSPAN%3E%3CSPAN%3E%2C%3C%2FSPAN%3E%3CSPAN%3E6%3C%2FSPAN%3E%3CSPAN%3E)%3C%2FSPAN%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3EWrite-Host%3C%2FSPAN%3E%20%3CSPAN%3E%22%20%22%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EWrite-Host%3C%2FSPAN%3E%20%3CSPAN%3E%22Compliance%20Search%20Size%3A%22%3C%2FSPAN%3E%20%3CSPAN%3E%24Size%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EWrite-Host%3C%2FSPAN%3E%20%3CSPAN%3E%22Downloaded%20Size%3A%22%3C%2FSPAN%3E%20%3CSPAN%3E%24DownloadSize%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EWrite-Host%3C%2FSPAN%3E%20%3CSPAN%3E%22%20%22%3C%2FSPAN%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3E%23Read-Host%20%22Pausing%20script%20until%20you%20verify%20download.%20Seriously.%20If%20the%20download%20isn't%20done%20this%20gets%20really%20bad.%20You%20sure%20you're%20ready%3F%20Press%20enter%20to%20continue%22%3C%2FSPAN%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3ELogWrite%20%3C%2FSPAN%3E%3CSPAN%3E%22PST%20exported%20%26amp%3B%20downloaded%22%3C%2FSPAN%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3E%23Remove%20compliance%20search%20%26amp%3B%20export%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%24ExportName%3C%2FSPAN%3E%20%3CSPAN%3E%3D%3C%2FSPAN%3E%20%3CSPAN%3E%24SearchName%3C%2FSPAN%3E%20%3CSPAN%3E%2B%3C%2FSPAN%3E%20%3CSPAN%3E%22_Export%22%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3ERemove-ComplianceSearchAction%3C%2FSPAN%3E%20%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EIdentity%20%3C%2FSPAN%3E%3CSPAN%3E%24ExportName%3C%2FSPAN%3E%20%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EConfirm%3A%3C%2FSPAN%3E%3CSPAN%3E%24False%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3ERemove-ComplianceSearch%3C%2FSPAN%3E%20%3CSPAN%3E%24SearchName%3C%2FSPAN%3E%20%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EConfirm%3A%3C%2FSPAN%3E%3CSPAN%3E%24False%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EIf%3C%2FSPAN%3E%3CSPAN%3E(%24%3C%2FSPAN%3E%3CSPAN%3E%3F%3C%2FSPAN%3E%3CSPAN%3E)%7B%3C%2FSPAN%3E%3CSPAN%3EWrite-Host%3C%2FSPAN%3E%20%3CSPAN%3E%22Compliance%20search%20%26amp%3B%20export%20removed%22%3C%2FSPAN%3E%3CSPAN%3E%7D%3C%2FSPAN%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3E%23Get%20%26amp%3B%20Remove%20O365%20licenses%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%24UPN2%3C%2FSPAN%3E%20%3CSPAN%3E%3D%3C%2FSPAN%3E%20%3CSPAN%3EGet-ADUser%3C%2FSPAN%3E%20%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EIdentity%20%3C%2FSPAN%3E%3CSPAN%3E%24User%3C%2FSPAN%3E%20%3CSPAN%3E%7C%3C%2FSPAN%3E%20%3CSPAN%3EForEach-Object%3C%2FSPAN%3E%3CSPAN%3E%7B%24_%3C%2FSPAN%3E%3CSPAN%3E.UserPrincipalName%3C%2FSPAN%3E%3CSPAN%3E%7D%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%24MSOLUser%3C%2FSPAN%3E%20%3CSPAN%3E%3D%3C%2FSPAN%3E%20%3CSPAN%3EGet-MsolUser%3C%2FSPAN%3E%20%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EUserPrincipalName%20%3C%2FSPAN%3E%3CSPAN%3E%24UPN2%3C%2FSPAN%3E%20%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EErrorAction%20SilentlyContinue%3C%2FSPAN%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3E%23%24IsLicensed%20%3D%20%24MSOLUser.IsLicensed%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%24Licenses%3C%2FSPAN%3E%20%3CSPAN%3E%3D%3C%2FSPAN%3E%20%3CSPAN%3E%24MSOLUser.Licenses%3C%2FSPAN%3E%3CSPAN%3E%5B%3C%2FSPAN%3E%3CSPAN%3E0%3C%2FSPAN%3E%3CSPAN%3E%5D.AccountSkuId%3C%2FSPAN%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3ESet-MsolUserLicense%3C%2FSPAN%3E%20%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EUserPrincipalName%20%3C%2FSPAN%3E%3CSPAN%3E%24UPN2%3C%2FSPAN%3E%20%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3ERemoveLicenses%20%3C%2FSPAN%3E%3CSPAN%3E%24Licenses%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EIf%3C%2FSPAN%3E%3CSPAN%3E(%24%3C%2FSPAN%3E%3CSPAN%3E%3F%3C%2FSPAN%3E%3CSPAN%3E)%7B%3C%2FSPAN%3E%3CSPAN%3EWrite-Host%3C%2FSPAN%3E%20%3CSPAN%3E%22%3C%2FSPAN%3E%3CSPAN%3E%24User%3C%2FSPAN%3E%20%3CSPAN%3E%24Licenses%3C%2FSPAN%3E%3CSPAN%3E%20removed%22%3C%2FSPAN%3E%3CSPAN%3E%7D%3C%2FSPAN%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3E%23Move%20to%20Disabled%20Accts%20OU%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EGet-AdUser%3C%2FSPAN%3E%20%3CSPAN%3E%24User%3C%2FSPAN%3E%20%3CSPAN%3E%7C%3C%2FSPAN%3E%20%3CSPAN%3EMove-AdObject%3C%2FSPAN%3E%20%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3ETargetPath%20%3C%2FSPAN%3E%3CSPAN%3E%22%22%3C%2FSPAN%3E%20%3CSPAN%3E%23Moves%20to%20an%20OU%20that%20doesnt%20sync%20to%20O365%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3ELogWrite%20%3C%2FSPAN%3E%3CSPAN%3E%22%3C%2FSPAN%3E%3CSPAN%3E%24User%3C%2FSPAN%3E%3CSPAN%3E%20account%20has%20been%20moved%20to%20Disabled%20Accts%20OU%22%3C%2FSPAN%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3E%23Run%20DirSync%20on%20Azure%20AD%20Connect%20sync%20server%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EInvoke-Command%3C%2FSPAN%3E%20%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EComputername%20%3C%2FSPAN%3E%3CSPAN%3E%22%22%3C%2FSPAN%3E%20%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EScriptBlock%20%7BC%3A%5CDirSync%3C%2FSPAN%3E%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EForceDelta.ps1%7D%20%3C%2FSPAN%3E%3CSPAN%3E%23Runs%20an%20Azure%20AD%20Connect%20Directory%20sync%20on%20a%20remote%20server%3C%2FSPAN%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3E%23Move%20PST%20for%20upload%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EGet-Childitem%3C%2FSPAN%3E%20%3CSPAN%3E%22C%3A%5Cpst%22%3C%2FSPAN%3E%20%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3Erecurse%20%3C%2FSPAN%3E%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3Einclude%20%3C%2FSPAN%3E%3CSPAN%3E*%3C%2FSPAN%3E%3CSPAN%3E.pst%20%3C%2FSPAN%3E%3CSPAN%3E%7C%3C%2FSPAN%3E%20%3CSPAN%3EMove-Item%3C%2FSPAN%3E%20%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EDestination%20%3C%2FSPAN%3E%3CSPAN%3E%22C%3A%5Cpst%22%3C%2FSPAN%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3E%23Upload%20mailbox%20to%20Azure%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EWrite-Host%3C%2FSPAN%3E%20%3CSPAN%3E%22Uploading%20to%20Azure%22%3C%2FSPAN%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3EStart-Process%3C%2FSPAN%3E%20%3CSPAN%3E%22Disable%20User%20Process%5CLaunchCmd-Custom.cmd%22%3C%2FSPAN%3E%20%3CSPAN%3E%23Customized%20Azure%20Storage%20AZ%20copy%20upload%20script%3C%2FSPAN%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3E%23Confirm%20upload%20to%20finished%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3Ewrite-host%3C%2FSPAN%3E%20%3CSPAN%3E%22%20%22%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%24confirmation%3C%2FSPAN%3E%20%3CSPAN%3E%3D%3C%2FSPAN%3E%20%3CSPAN%3ERead-Host%3C%2FSPAN%3E%20%3CSPAN%3E%22Did%20Azure%20upload%20complete%20successfully%3F%20You%20need%20to%20enter%20y%20here%22%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3Eif%3C%2FSPAN%3E%3CSPAN%3E%20(%3C%2FSPAN%3E%3CSPAN%3E%24confirmation%3C%2FSPAN%3E%20%3CSPAN%3E-eq%3C%2FSPAN%3E%20%3CSPAN%3E'y'%3C%2FSPAN%3E%3CSPAN%3E)%7B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%23Delete%20pst%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3ERemove-Item%3C%2FSPAN%3E%20%3CSPAN%3E%22C%3A%5Cpst%5C*%22%3C%2FSPAN%3E%20%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3ERecurse%20%3C%2FSPAN%3E%3CSPAN%3E-%3C%2FSPAN%3E%3CSPAN%3EConfirm%3A%3C%2FSPAN%3E%3CSPAN%3E%24False%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EIf%3C%2FSPAN%3E%3CSPAN%3E(%24%3C%2FSPAN%3E%3CSPAN%3E%3F%3C%2FSPAN%3E%3CSPAN%3E)%7B%3C%2FSPAN%3E%3CSPAN%3EWrite-host%3C%2FSPAN%3E%20%3CSPAN%3E%22%20%22%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EWrite-Host%3C%2FSPAN%3E%20%3CSPAN%3E%22PST%20Deleted%22%3C%2FSPAN%3E%3CSPAN%3E%7D%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%7D%3C%2FSPAN%3E%3C%2FDIV%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EAlso%2C%20here%20is%20the%20AZ%20copy%20script%2C%20you%20need%20to%20get%20your%20own%20key%20and%20destination%20info.%20I%20honestly%20forget%20how%20to%20get%20that.%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CDIV%3E%3CDIV%3E%3CSPAN%3E%40echo%3C%2FSPAN%3E%3CSPAN%3E%20off%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3Etitle%20Microsoft%20Azure%20Storage%20tools%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3Eset%20LaunchCmdFolder%3C%2FSPAN%3E%3CSPAN%3E%3D%3C%2FSPAN%3E%3CSPAN%3E%22C%3A%5CProgram%20Files%20(x86)%5CMicrosoft%20SDKs%5CAzure%5CAzCopy%22%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3Eset%20PATH%3C%2FSPAN%3E%3CSPAN%3E%3D%25%3C%2FSPAN%3E%3CSPAN%3EPATH%3C%2FSPAN%3E%3CSPAN%3E%25%3C%2FSPAN%3E%3CSPAN%3E%3B%3C%2FSPAN%3E%3CSPAN%3E%25%3C%2FSPAN%3E%3CSPAN%3ELaunchCmdFolder%3C%2FSPAN%3E%3CSPAN%3E%25%3C%2FSPAN%3E%3CSPAN%3EAzCopy%3C%2FSPAN%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3ESet%20azcopy%3C%2FSPAN%3E%3CSPAN%3E%3D%3C%2FSPAN%3E%3CSPAN%3E%22C%3A%5CProgram%20Files%20(x86)%5CMicrosoft%20SDKs%5CAzure%5CAzCopy%5CAzCopy.exe%22%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3ESet%20source%3C%2FSPAN%3E%3CSPAN%3E%3D%3C%2FSPAN%3E%3CSPAN%3E%22C%3A%5Cpst%22%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3ESet%20dest%3C%2FSPAN%3E%3CSPAN%3E%3D%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3Eset%20key%3C%2FSPAN%3E%3CSPAN%3E%3D%3C%2FSPAN%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3E%25%3C%2FSPAN%3E%3CSPAN%3Eazcopy%3C%2FSPAN%3E%3CSPAN%3E%25%3C%2FSPAN%3E%20%3CSPAN%3E%2F%3C%2FSPAN%3E%3CSPAN%3Esource%3A%3C%2FSPAN%3E%3CSPAN%3E%25%3C%2FSPAN%3E%3CSPAN%3Esource%3C%2FSPAN%3E%3CSPAN%3E%25%3C%2FSPAN%3E%20%3CSPAN%3E%2F%3C%2FSPAN%3E%3CSPAN%3EDest%3A%3C%2FSPAN%3E%3CSPAN%3E%25%3C%2FSPAN%3E%3CSPAN%3Edest%3C%2FSPAN%3E%3CSPAN%3E%25%3C%2FSPAN%3E%20%3CSPAN%3E%2F%3C%2FSPAN%3E%3CSPAN%3EDestKey%3A%3C%2FSPAN%3E%3CSPAN%3E%25%3C%2FSPAN%3E%3CSPAN%3Ekey%3C%2FSPAN%3E%3CSPAN%3E%25%3C%2FSPAN%3E%20%3CSPAN%3E%2F%3C%2FSPAN%3E%3CSPAN%3EPattern%3A%3C%2FSPAN%3E%3CSPAN%3E*%3C%2FSPAN%3E%3CSPAN%3E.pst%20%3C%2FSPAN%3E%3CSPAN%3E%2F%3C%2FSPAN%3E%3CSPAN%3ES%20%3C%2FSPAN%3E%3CSPAN%3E%2F%3C%2FSPAN%3E%3CSPAN%3EV%3AC%3A%5CAZCopy.log%3C%2FSPAN%3E%3C%2FDIV%3E%3CBR%20%2F%3E%3CDIV%3E%3CSPAN%3EPause%3C%2FSPAN%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1357754%22%20slang%3D%22en-US%22%3ERe%3A%20Export%20to%20PST%20via%20Powershell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1357754%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F229846%22%20target%3D%22_blank%22%3E%40Tom%20Aguero%3C%2FA%3E%26nbsp%3BThanks%20for%20the%20help%20so%20far.%3CBR%20%2F%3E%3CBR%20%2F%3EI%20am%20not%20able%20to%20start%20the%20export.%3C%2FP%3E%3CP%3EFrom%20the%20tracert%20file%20i%20got%20this%20message%3A%3CBR%20%2F%3EUnhandled%20Exception%3A%20System.IO.FileNotFoundException%3A%20Could%20not%20load%20file%20or%20assembly%20'Microsoft.Office.Client.Discovery.UnifiedExport%2C%20Version%3D15.0.0.0%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3D31bf3856ad364e35'%20or%20one%20of%20its%20dependencies.%20The%20system%20cannot%20find%20the%20file%20specified.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EDo%20I%20need%20to%20do%20something%20with%20the%26nbsp%3BMicrosoft.Office.Client.Discovery.UnifiedExportTool.application%20file%20or%20should%20it%20work%20with%26nbsp%3BContainer%20url%20and%26nbsp%3BSAS%20token%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20also%20fund%20this%20(he%20has%20stolen%20some%20part%20from%20you).%20Still%20no%20luck.%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Fwww.reddit.com%2Fr%2FPowerShell%2Fcomments%2Fba4fpu%2Fautomated_download_of_o365_inbox_archive%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fwww.reddit.com%2Fr%2FPowerShell%2Fcomments%2Fba4fpu%2Fautomated_download_of_o365_inbox_archive%2F%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAny%20help%20is%20appreciated%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1358053%22%20slang%3D%22en-US%22%3ERe%3A%20Export%20to%20PST%20via%20Powershell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1358053%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F646783%22%20target%3D%22_blank%22%3E%40Powershell_mannen69%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIt%20looks%20like%20the%20export%20tool%20can't%20load%20one%20of%20it's%20dependency%20files.%20Did%20you%20copy%20the%20exe%20out%20of%20your%20profile%20folder%20without%20all%20the%20rest%20of%20the%20files%3F%20And%2C%20are%20you%20using%20Tom%20Aguero's%20code%3F%20If%20so%2C%20try%20replacing%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3E%24exportexe%26nbsp%3B%3D%26nbsp%3B%22%5CUnifiedExportTool%5Cmicrosoft.office.client.discovery.unifiedexporttool.exe%22%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ewith%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3E%24exportexe%20%3D%20((Get-ChildItem%20-Path%20%24(%24env%3ALOCALAPPDATA%20%2B%20%22%5CApps%5C2.0%5C%22)%20-Filter%20microsoft.office.client.discovery.unifiedexporttool.exe%20-Recurse).FullName%20%7C%20Where-Object%7B%20%24_%20-notmatch%20%22_none_%22%20%7D%20%7C%20Select-Object%20-First%201)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eand%20see%20if%20that%20helps%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20should%20find%20the%20exe%20within%20your%20profile%2C%20without%20having%20to%20copy%20the%20file%20or%20use%20any%20static%20paths%2C%20which%20should%20help%20if%20you%20have%20multiple%20people%20that%20may%20run%20the%20script.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAlso%2C%20thanks%20for%20the%20Reddit%20link%2C%20I%20like%20their%20way%20of%20pulling%20the%20URL%20and%20token%20much%20better!%20I'll%20have%20to%20try%20it%20out%20on%20the%20next%20run%20of%20the%20script.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAdditionally%2C%20If%20anyone%20wants%20to%20automate%20downloading%20the%20unified%20export%20tool%3A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3E%23%20Check%20if%20the%20export%20tool%20is%20installed%20for%20the%20user%2C%20and%20download%20if%20not.%0AWhile%20(-Not%20((Get-ChildItem%20-Path%20%24(%24env%3ALOCALAPPDATA%20%2B%20%22%5CApps%5C2.0%5C%22)%20-Filter%20microsoft.office.client.discovery.unifiedexporttool.exe%20-Recurse).FullName%20%7C%20Where-Object%7B%20%24_%20-notmatch%20%22_none_%22%20%7D%20%7C%20Select-Object%20-First%201))%7B%0A%20%20%20%20Write-Host%20%22Downloading%20Unified%20Export%20Tool%20.%22%0A%20%20%20%20Write-Host%20%22This%20is%20installed%20per-user%20by%20the%20Click-Once%20installer.%22%0A%20%20%20%20%23%20Credit%20to%20Jos%20Verlinde%20for%20his%20code%20in%20Load-ExchangeMFA%20in%20the%20Powershell%20Gallery!%20All%20I've%20done%20is%20update%20the%20manifest%20url%20and%20remove%20all%20the%20comments%0A%20%20%20%20%23%20Ripped%20from%20https%3A%2F%2Fwww.powershellgallery.com%2Fpackages%2FLoad-ExchangeMFA%2F1.2%0A%20%20%20%20%23%20In%20case%20anyone%20else%20has%20any%20ClickOnce%20applications%20they'd%20like%20to%20automate%20the%20install%20for%3A%0A%20%20%20%20%23%20If%20you're%20looking%20for%20where%20to%20find%20a%20manifest%20URL%2C%20once%20you%20have%20run%20the%20ClickOnce%20application%20at%20least%20once%20on%20your%20computer%2C%20the%20url%20for%20the%20application%20manifest%20can%20be%20found%20in%20the%20Windows%20Registry%20at%20%22HKEY_CURRENT_USER%5CSoftware%5CMicrosoft%5CWindows%5CCurrentVersion%5CUninstall%22%20(yes%2C%20CTR%20apps%20are%20installed%20per-user).%0A%20%20%20%20%23%20Look%20through%20the%20keys%20with%20names%20that%20are%2016%20characters%20long%20hex%20strings.%20They'll%20have%20a%20string%20value%20(REG_SZ)%20named%20either%20%22ShortcutAppId%22%20or%20%22UrlUpdateInfo%22%20that%20contains%20the%20URL%20as%20the%20first%20part%20of%20the%20string.%0A%20%20%20%20%24Manifest%20%3D%20%22https%3A%2F%2Fcomplianceclientsdf.blob.core.windows.net%2Fv16%2FMicrosoft.Office.Client.Discovery.UnifiedExportTool.application%22%0A%20%20%20%20%24ElevatePermissions%20%3D%20%24true%0A%20%20%20%20Try%20%7B%0A%20%20%20%20%20%20%20%20Add-Type%20-AssemblyName%20System.Deployment%0A%20%20%20%20%20%20%20%20Write-Host%20%22Starting%20installation%20of%20ClickOnce%20Application%20%24Manifest%20%22%0A%20%20%20%20%20%20%20%20%24RemoteURI%20%3D%20%5BURI%5D%3A%3ANew(%20%24Manifest%20%2C%20%5BUriKind%5D%3A%3AAbsolute)%0A%20%20%20%20%20%20%20%20if%20(-not%20%20%24Manifest)%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20throw%20%22Invalid%20ConnectionUri%20parameter%20'%24ConnectionUri'%22%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%24HostingManager%20%3D%20New-Object%20System.Deployment.Application.InPlaceHostingManager%20-ArgumentList%20%24RemoteURI%20%2C%20%24False%0A%20%20%20%20%20%20%20%20Register-ObjectEvent%20-InputObject%20%24HostingManager%20-EventName%20GetManifestCompleted%20-Action%20%7B%20%0A%20%20%20%20%20%20%20%20%20%20%20%20new-event%20-SourceIdentifier%20%22ManifestDownloadComplete%22%0A%20%20%20%20%20%20%20%20%7D%20%7C%20Out-Null%0A%20%20%20%20%20%20%20%20Register-ObjectEvent%20-InputObject%20%24HostingManager%20-EventName%20DownloadApplicationCompleted%20-Action%20%7B%20%0A%20%20%20%20%20%20%20%20%20%20%20%20new-event%20-SourceIdentifier%20%22DownloadApplicationCompleted%22%0A%20%20%20%20%20%20%20%20%7D%20%7C%20Out-Null%0A%20%20%20%20%20%20%20%20%24HostingManager.GetManifestAsync()%0A%20%20%20%20%20%20%20%20%24event%20%3D%20Wait-Event%20-SourceIdentifier%20%22ManifestDownloadComplete%22%20-Timeout%2015%0A%20%20%20%20%20%20%20%20if%20(%24event%20)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%24event%20%7C%20Remove-Event%0A%20%20%20%20%20%20%20%20%20%20%20%20Write-Host%20%22ClickOnce%20Manifest%20Download%20Completed%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%24HostingManager.AssertApplicationRequirements(%24ElevatePermissions)%0A%20%20%20%20%20%20%20%20%20%20%20%20%24HostingManager.DownloadApplicationAsync()%0A%20%20%20%20%20%20%20%20%20%20%20%20%24event%20%3D%20Wait-Event%20-SourceIdentifier%20%22DownloadApplicationCompleted%22%20-Timeout%2060%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20(%24event%20)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%24event%20%7C%20Remove-Event%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Write-Host%20%22ClickOnce%20Application%20Download%20Completed%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20else%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Write-error%20%22ClickOnce%20Application%20Download%20did%20not%20complete%20in%20time%20(60s)%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20else%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20Write-error%20%22ClickOnce%20Manifest%20Download%20did%20not%20complete%20in%20time%20(15s)%22%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%20%20%20finally%20%7B%0A%20%20%20%20%20%20%20%20Get-EventSubscriber%7C%3F%20%7B%24_.SourceObject.ToString()%20-eq%20'System.Deployment.Application.InPlaceHostingManager'%7D%20%7C%20Unregister-Event%0A%20%20%20%20%7D%0A%7D%0A%0A%24exportexe%20%3D%20((Get-ChildItem%20-Path%20%24(%24env%3ALOCALAPPDATA%20%2B%20%22%5CApps%5C2.0%5C%22)%20-Filter%20microsoft.office.client.discovery.unifiedexporttool.exe%20-Recurse).FullName%20%7C%20Where-Object%7B%20%24_%20-notmatch%20%22_none_%22%20%7D%20%7C%20Select-Object%20-First%201)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-193934%22%20slang%3D%22en-US%22%3ERe%3A%20Export%20to%20PST%20via%20Powershell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-193934%22%20slang%3D%22en-US%22%3E%3CP%3ESo%2C%20I've%20been%20fighting%20to%20automate%20using%20powershell%20to%20export%20a%20PST%20from%20Office%20365%20off%20and%20on%20for%20a%20while.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAzCopy%20worked%20great%20for%20Sharepoint%2FOneDrive%20exports%2C%20but%20exchange%20data%20all%20came%20down%20as%20%22.batch%22%20files%2C%20which%20appear%20to%20need%20further%20post-processing%20to%20collect%20everything%20into%20a%20PST.%20Someone%20better%20than%20I%20might%20know%20how%20to%20piece%20them%20together%2C%20but%20I%20just%26nbsp%3Bmoved%20on.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIt's%20a%20bit%20of%20a%20workaround%20but%20here's%20what%20I%20did%20to%20automate%20the%20PST%20download.%3C%2FP%3E%3CP%3EWhen%20you%20manually%20download%20the%20export%20using%20the%20export%20tool%2C%20the%20click-once%20popup%20downloads%20their%20%22Unified%26nbsp%3BExport%20Tool%22%20and%20populates%20it%20with%20what%20it%20needs%20to%20get%20it%20going.%20While%20it's%20open%2C%20you%20can%20right-click%20the%20process%20in%20task%20manager%20and%20click%20%22Open%20file%20location%22.%20This%20will%20take%20you%20to%20the%20files%20their%20tool%20uses%2C%20in%20your%20appdata.%20For%20me%2C%20this%20location%20was%20%22%25LOCALAPPDATA%25%5CApps%5C2.0%5CQBKH9EZX.XMP%5C7R4KYC02.WJ7%5Cmicr..tool_51a5b647dacf4059_000f.0014_a4b60912e622c727%5C%22%3C%2FP%3E%3CP%3EI'm%20sure%20Microsoft%20updates%20the%20tool%20every%20now%20and%20then%2C%20so%20this%20path%20may%20not%20work%20indefinitely.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAnyways%2C%20I%20just%20copied%20everything%20to%20a%20new%20folder%20(I%20don't%20recommend%20doing%20this%2C%20i%20provide%20an%20example%20to%20find%20the%20file%20automatically%20in%20the%20script%20below)%20and%20ran%20the%20%22microsoft.office.client.discovery.unifiedexporttool.exe%22%20which%20returned%20the%20parameters%20that%20it%20accepts.%20Much%20like%20AzCopy%2C%20it%20looks%20for%20the%20URL%2C%20Token%2C%20and%20a%20place%20to%20drop%20the%20files.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHere's%20what%20I%20slapped%20together%20to%20automatically%20download%20the%20export%20from%20Office%20365%3A%3C%2FP%3E%3CP%3E%3CEM%3EThe%20code%20below%20has%20been%20edited%20since%20this%20post%20was%20created%20to%20include%20improvements%20to%20the%20original%20code%20and%20provide%20a%20start%20to%20finish%20example%20to%20export%20and%20download%20a%20PST.%20If%20you%20want%20to%20use%20this%20as%20a%20user%20off-boarding%20script%20you'll%20need%20to%20add%20those%20tasks%20as%20well.%20Everyone%20has%20their%20own%20processes%2C%20but%20Tom%20Aguero's%20post%20below%20has%20some%20good%20examples%20too.%3C%2FEM%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3E%23%20Note%20that%20I'm%20not%20validating%20any%20input%20or%20providing%20any%20adequate%20error%20handling.%0A%23%20This%20is%20just%20an%20example%2C%20you'll%20need%20to%20add%20these%20in%20yourself.%0A%0AParam(%0A%20%20%20%20%5BParameter(Mandatory%3D%24True%2C%20HelpMessage%3D'Enter%20the%20email%20address%20that%20you%20want%20to%20export')%5D%0A%20%20%20%20%24Mailbox%2C%0A%20%20%20%20%5BParameter(Mandatory%3D%24True%2C%20HelpMessage%3D'Enter%20the%20URL%20for%20the%20user''s%20OneDrive%20here.%20If%20you%20don''t%20enter%20one%2C%20this%20will%20be%20skipped.')%5D%0A%20%20%20%20%24OneDriveURL%2C%0A%20%20%20%20%5BParameter(Mandatory%3D%24True%2C%20HelpMessage%3D'Enter%20the%20path%20where%20you%20want%20to%20save%20the%20PST%20file.%20!NO%20TRAILING%20BACKSLASH!')%5D%0A%20%20%20%20%24ExportLocation%20%23%20%3D%20%22%22%23%20you%20can%20un-comment%20the%20%3D%20%22%22%20to%20set%20a%20default%20for%20this%20parameter.%0A)%0A%0A%23%20Create%20a%20search%20name.%20You%20can%20change%20this%20to%20suit%20your%20preference%0A%24SearchName%20%3D%20%22%24Mailbox%20PST%22%0A%0A%23%20I'm%20using%20the%20Exchange%20Online%20Powershell%20Module%20v2.%20You%20can%20install%20it%20from%20an%20admin%20session%20with%20the%20following%20command%3A%20Install-Module%20ExchangeOnlineManagement%0AWrite-Host%20%22Connecting%20to%20Exchange%20Online.%20Enter%20your%20admin%20credentials%20in%20the%20pop-up%20(pop-under%3F)%20window.%22%0AConnect-IPPSSession%0A%0AWrite-Host%20%22Creating%20compliance%20search...%22%0ANew-ComplianceSearch%20-Name%20%24SearchName%20-ExchangeLocation%20%24Mailbox%20-SharePointLocation%20%24OneDriveURL%20-AllowNotFoundExchangeLocationsEnabled%20%24true%20%23Create%20a%20content%20search%2C%20including%20the%20the%20entire%20contents%20of%20the%20user's%20email%20and%20onedrive.%20If%20you%20didn't%20provide%20a%20OneDrive%20URL%2C%20or%20it%20wasn't%20valid%2C%20it%20will%20be%20ignored.%0AWrite-Host%20%22Starting%20compliance%20search...%22%0AStart-ComplianceSearch%20-Identity%20%24SearchName%20%23Start%20the%20search%20created%20above%0AWrite-Host%20%22Waiting%20for%20compliance%20search%20to%20complete...%22%0Afor%20(%24SearchStatus%3B%24SearchStatus%20-notlike%20%22Completed%22%3B)%7B%20%23Wait%20then%20check%20if%20the%20search%20is%20complete%2C%20loop%20until%20complete%0A%20%20%20%20Start-Sleep%20-s%202%0A%20%20%20%20%24SearchStatus%20%3D%20Get-ComplianceSearch%20%24SearchName%20%7C%20Select-Object%20-ExpandProperty%20Status%20%23Get%20the%20status%20of%20the%20search%0A%20%20%20%20Write-Host%20-NoNewline%20%22.%22%20%23%20Show%20some%20sort%20of%20status%20change%20in%20the%20terminal%0A%7D%0AWrite-Host%20%22Compliance%20search%20is%20complete!%22%0AWrite-Host%20%22Creating%20export%20from%20the%20search...%22%0ANew-ComplianceSearchAction%20-SearchName%20%24SearchName%20-Export%20-Format%20FxStream%20-ExchangeArchiveFormat%20PerUserPst%20-Scope%20BothIndexedAndUnindexedItems%20-EnableDedupe%20%24true%20-SharePointArchiveFormat%20IndividualMessage%20-IncludeSharePointDocumentVersions%20%24true%20%0AStart-Sleep%20-s%205%20%23%20Arbitrarily%20wait%205%20seconds%20to%20give%20microsoft's%20side%20time%20to%20create%20the%20SearchAction%20before%20the%20next%20commands%20try%20to%20run%20against%20it.%20I%20%2FCOULD%2F%20do%20a%20for%20loop%20and%20check%2C%20but%20it's%20really%20not%20worth%20it.%0A%0A%23%20Check%20if%20the%20export%20tool%20is%20installed%20for%20the%20user%2C%20and%20download%20if%20not.%0AWhile%20(-Not%20((Get-ChildItem%20-Path%20%24(%24env%3ALOCALAPPDATA%20%2B%20%22%5CApps%5C2.0%5C%22)%20-Filter%20microsoft.office.client.discovery.unifiedexporttool.exe%20-Recurse).FullName%20%7C%20Where-Object%7B%20%24_%20-notmatch%20%22_none_%22%20%7D%20%7C%20Select-Object%20-First%201))%7B%0A%20%20%20%20Write-Host%20%22Downloading%20Unified%20Export%20Tool%20.%22%0A%20%20%20%20Write-Host%20%22This%20is%20installed%20per-user%20by%20the%20Click-Once%20installer.%22%0A%20%20%20%20%23%20Credit%20to%20Jos%20Verlinde%20for%20his%20code%20in%20Load-ExchangeMFA%20in%20the%20Powershell%20Gallery!%20All%20I've%20done%20is%20update%20the%20manifest%20url%20and%20remove%20all%20the%20comments%0A%20%20%20%20%23%20Ripped%20from%20https%3A%2F%2Fwww.powershellgallery.com%2Fpackages%2FLoad-ExchangeMFA%2F1.2%0A%20%20%20%20%23%20In%20case%20anyone%20else%20has%20any%20ClickOnce%20applications%20they'd%20like%20to%20automate%20the%20install%20for%3A%0A%20%20%20%20%23%20If%20you're%20looking%20for%20where%20to%20find%20a%20manifest%20URL%2C%20once%20you%20have%20run%20the%20ClickOnce%20application%20at%20least%20once%20on%20your%20computer%2C%20the%20url%20for%20the%20application%20manifest%20can%20be%20found%20in%20the%20Windows%20Registry%20at%20%22HKEY_CURRENT_USER%5CSoftware%5CMicrosoft%5CWindows%5CCurrentVersion%5CUninstall%22%20(yes%2C%20CTR%20apps%20are%20installed%20per-user).%0A%20%20%20%20%23%20Look%20through%20the%20keys%20with%20names%20that%20are%2016%20characters%20long%20hex%20strings.%20They'll%20have%20a%20string%20value%20(REG_SZ)%20named%20either%20%22ShortcutAppId%22%20or%20%22UrlUpdateInfo%22%20that%20contains%20the%20URL%20as%20the%20first%20part%20of%20the%20string.%0A%20%20%20%20%24Manifest%20%3D%20%22https%3A%2F%2Fcomplianceclientsdf.blob.core.windows.net%2Fv16%2FMicrosoft.Office.Client.Discovery.UnifiedExportTool.application%22%0A%20%20%20%20%24ElevatePermissions%20%3D%20%24true%0A%20%20%20%20Try%20%7B%0A%20%20%20%20%20%20%20%20Add-Type%20-AssemblyName%20System.Deployment%0A%20%20%20%20%20%20%20%20Write-Host%20%22Starting%20installation%20of%20ClickOnce%20Application%20%24Manifest%20%22%0A%20%20%20%20%20%20%20%20%24RemoteURI%20%3D%20%5BURI%5D%3A%3ANew(%20%24Manifest%20%2C%20%5BUriKind%5D%3A%3AAbsolute)%0A%20%20%20%20%20%20%20%20if%20(-not%20%20%24Manifest)%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20throw%20%22Invalid%20ConnectionUri%20parameter%20'%24ConnectionUri'%22%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%24HostingManager%20%3D%20New-Object%20System.Deployment.Application.InPlaceHostingManager%20-ArgumentList%20%24RemoteURI%20%2C%20%24False%0A%20%20%20%20%20%20%20%20Register-ObjectEvent%20-InputObject%20%24HostingManager%20-EventName%20GetManifestCompleted%20-Action%20%7B%20%0A%20%20%20%20%20%20%20%20%20%20%20%20new-event%20-SourceIdentifier%20%22ManifestDownloadComplete%22%0A%20%20%20%20%20%20%20%20%7D%20%7C%20Out-Null%0A%20%20%20%20%20%20%20%20Register-ObjectEvent%20-InputObject%20%24HostingManager%20-EventName%20DownloadApplicationCompleted%20-Action%20%7B%20%0A%20%20%20%20%20%20%20%20%20%20%20%20new-event%20-SourceIdentifier%20%22DownloadApplicationCompleted%22%0A%20%20%20%20%20%20%20%20%7D%20%7C%20Out-Null%0A%20%20%20%20%20%20%20%20%24HostingManager.GetManifestAsync()%0A%20%20%20%20%20%20%20%20%24event%20%3D%20Wait-Event%20-SourceIdentifier%20%22ManifestDownloadComplete%22%20-Timeout%2015%0A%20%20%20%20%20%20%20%20if%20(%24event%20)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%24event%20%7C%20Remove-Event%0A%20%20%20%20%20%20%20%20%20%20%20%20Write-Host%20%22ClickOnce%20Manifest%20Download%20Completed%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%24HostingManager.AssertApplicationRequirements(%24ElevatePermissions)%0A%20%20%20%20%20%20%20%20%20%20%20%20%24HostingManager.DownloadApplicationAsync()%0A%20%20%20%20%20%20%20%20%20%20%20%20%24event%20%3D%20Wait-Event%20-SourceIdentifier%20%22DownloadApplicationCompleted%22%20-Timeout%2060%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20(%24event%20)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%24event%20%7C%20Remove-Event%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Write-Host%20%22ClickOnce%20Application%20Download%20Completed%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20else%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Write-error%20%22ClickOnce%20Application%20Download%20did%20not%20complete%20in%20time%20(60s)%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20else%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20Write-error%20%22ClickOnce%20Manifest%20Download%20did%20not%20complete%20in%20time%20(15s)%22%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%20%20%20finally%20%7B%0A%20%20%20%20%20%20%20%20Get-EventSubscriber%7C%3F%20%7B%24_.SourceObject.ToString()%20-eq%20'System.Deployment.Application.InPlaceHostingManager'%7D%20%7C%20Unregister-Event%0A%20%20%20%20%7D%0A%7D%0A%0A%23%20Find%20the%20Unified%20Export%20Tool's%20location%20and%20create%20a%20variable%20for%20it%0A%24ExportExe%20%3D%20((Get-ChildItem%20-Path%20%24(%24env%3ALOCALAPPDATA%20%2B%20%22%5CApps%5C2.0%5C%22)%20-Filter%20microsoft.office.client.discovery.unifiedexporttool.exe%20-Recurse).FullName%20%7C%20Where-Object%7B%20%24_%20-notmatch%20%22_none_%22%20%7D%20%7C%20Select-Object%20-First%201)%0A%0A%23%20Gather%20the%20URL%20and%20Token%20from%20the%20export%20in%20order%20to%20start%20the%20download%0A%23%20We%20only%20need%20the%20ContainerURL%20and%20SAS%20Token%20at%20a%20minimum%20but%20we're%20also%20pulling%20others%20to%20help%20with%20tracking%20the%20status%20of%20the%20export.%0A%24ExportName%20%3D%20%24SearchName%20%2B%20%22_Export%22%0A%24ExportDetails%20%3D%20Get-ComplianceSearchAction%20-Identity%20%24ExportName%20-IncludeCredential%20-Details%20%23%20Get%20details%20for%20the%20export%20action%0A%23%20This%20method%20of%20splitting%20the%20Container%20URL%20and%20Token%20from%20%24ExportDetails%20is%20thanks%20to%20schmeckendeugler%20from%20reddit%3A%20https%3A%2F%2Fwww.reddit.com%2Fr%2FPowerShell%2Fcomments%2Fba4fpu%2Fautomated_download_of_o365_inbox_archive%2F%0A%23%20I%20was%20using%20Convert-FromString%20before%2C%20which%20was%20slow%20and%20terrible.%20His%20way%20is%20MUCH%20better.%0A%24ExportDetails%20%3D%20%24ExportDetails.Results.split(%22%3B%22)%0A%24ExportContainerUrl%20%3D%20%24ExportDetails%5B0%5D.trimStart(%22Container%20url%3A%20%22)%0A%24ExportSasToken%20%3D%20%24ExportDetails%5B1%5D.trimStart(%22%20SAS%20token%3A%20%22)%0A%24ExportEstSize%20%3D%20(%24ExportDetails%5B18%5D.TrimStart(%22%20Total%20estimated%20bytes%3A%20%22)%20-as%20%5Bdouble%5D)%0A%24ExportTransferred%20%3D%20(%24ExportDetails%5B20%5D.TrimStart(%22%20Total%20transferred%20bytes%3A%20%22)%20-as%20%5Bdouble%5D)%0A%24ExportProgress%20%3D%20%24ExportDetails%5B22%5D.TrimStart(%22%20Progress%3A%20%22).TrimEnd(%22%25%22)%0A%24ExportStatus%20%3D%20%24ExportDetails%5B25%5D.TrimStart(%22%20Export%20status%3A%20%22)%0A%0A%23%20Download%20the%20exported%20files%20from%20Office%20365%0AWrite-Host%20%22Initiating%20download%22%0AWrite-Host%20%22Saving%20export%20to%3A%20%22%20%2B%20%24ExportLocation%0A%24Arguments%20%3D%20%22-name%20%22%22%24SearchName%22%22%22%2C%22-source%20%22%22%24ExportContainerUrl%22%22%22%2C%22-key%20%22%22%24ExportSasToken%22%22%22%2C%22-dest%20%22%22%24ExportLocation%22%22%22%2C%22-trace%20true%22%0AStart-Process%20-FilePath%20%22%24ExportExe%22%20-ArgumentList%20%24Arguments%0A%0A%23%20The%20export%20is%20now%20downloading%20in%20the%20background.%20You%20can%20find%20it%20in%20task%20manager.%20Let's%20monitor%20the%20progress.%0A%23%20If%20you%20want%20to%20use%20this%20as%20part%20of%20a%20user%20offboarding%20script%2C%20add%20your%20edits%20above%20here%20-%20Exports%20can%20take%20a%20lot%20of%20time...%0A%23%20You%20can%20even%20comment%20this%20entire%20section%20and%20exit%20the%20script%20if%20you%20dont%20feel%20the%20need%20to%20monitor%20the%20download%2C%20it%20will%20keep%20downloading%20in%20the%20background%20even%20without%20the%20script%20running.%0A%23%20This%20is%20only%20monitoring%20if%20the%20process%20exists%2C%20which%20means%20if%20you%20run%20multiple%20exports%2C%20this%20will%20stay%20running%20until%20they%20all%20complete.%0A%23%20We%20could%20possibly%20utilize%20sysinternals%20handle.exe%20to%20identify%20the%20PID%20of%20the%20process%20writing%20to%20the%20%24Exportlocation%20and%20monitor%20for%20that%20specifically%2C%20but%20I'm%20trying%20to%20limit%20external%20applications%20in%20this%20example%20script.%0A%23%0A%23%20Just%20an%20FYI%2C%20the%20export%20progress%20is%20how%20much%20data%20Microsoft%20has%20copied%20into%20PSTs%20from%20the%20compliance%20search%2C%20not%20how%20much%20the%20export%20tool%20has%20downloaded.%0A%23%20We%20only%20know%20the%20actual%20size%20of%20the%20download%20after%20the%20%24ExportProgress%20is%20100%25%20and%20%24ExportStatus%20is%20Completed%0A%23%20The%20actual%20final%20size%20of%20the%20download%20is%20then%20reflected%20in%20%24ExportTransferred.%20Even%20then%2C%20our%20progress%20is%20still%20a%20bit%20inaccurate%20due%20to%20the%20extra%20log%20and%20temp%20files%20created%20locally%2C%20which%20will%20probably%20cause%20the%20progress%20to%20show%20over%20100%25%0A%23%20We%20could%20make%20this%20a%20bit%20more%20accurate%20by%20just%20collecting%20the%20size%20of%20PSTs%20and%20files%20under%20the%20OneDrive%20folder%2C%20but%20I%20think%20this%20brings%20us%20close%20enough%20for%20most%20situations.%0Awhile(Get-Process%20microsoft.office.client.discovery.unifiedexporttool%20-ErrorAction%20SilentlyContinue)%7B%0A%20%20%20%20%24Downloaded%20%3D%20Get-ChildItem%20%24ExportLocation%5C%24SearchName%20-Recurse%20%7C%20Measure-Object%20-Property%20Length%20-Sum%20%7C%20Select-Object%20-ExpandProperty%20Sum%0A%20%20%20%20Write-Progress%20-Id%201%20-Activity%20%22Export%20in%20Progress%22%20-Status%20%22Complete...%22%20-PercentComplete%20%24ExportProgress%0A%20%20%20%20if%20(%22Completed%22%20-notlike%20%24ExportStatus)%7BWrite-Progress%20-Id%202%20-Activity%20%22Download%20in%20Progress%22%20-Status%20%22Estimated%20Complete...%22%20-PercentComplete%20(%24Downloaded%2F%24ExportEstSize*100)%20-CurrentOperation%20%22%24Downloaded%2F%24ExportEstSize%20bytes%20downloaded.%22%7D%0A%20%20%20%20else%20%7BWrite-Progress%20-Id%202%20-Activity%20%22Download%20in%20Progress%22%20-Status%20%22Complete...%22%20-PercentComplete%20(%24Downloaded%2F%24ExportEstSize*100)%20-CurrentOperation%20%22%24Downloaded%2F%24ExportTransferred%20bytes%20downloaded.%22%7D%0A%20%20%20%20Start-Sleep%2060%0A%20%20%20%20%24ExportDetails%20%3D%20Get-ComplianceSearchAction%20-Identity%20%24ExportName%20-IncludeCredential%20-Details%20%23%20Get%20details%20for%20the%20export%20action%0A%20%20%20%20%24ExportDetails%20%3D%20%24ExportDetails.Results.split(%22%3B%22)%0A%20%20%20%20%24ExportEstSize%20%3D%20(%24ExportDetails%5B18%5D.TrimStart(%22%20Total%20estimated%20bytes%3A%20%22)%20-as%20%5Bdouble%5D)%0A%20%20%20%20%24ExportTransferred%20%3D%20(%24ExportDetails%5B20%5D.TrimStart(%22%20Total%20transferred%20bytes%3A%20%22)%20-as%20%5Bdouble%5D)%0A%20%20%20%20%24ExportProgress%20%3D%20%24ExportDetails%5B22%5D.TrimStart(%22%20Progress%3A%20%22).TrimEnd(%22%25%22)%0A%20%20%20%20%24ExportStatus%20%3D%20%24ExportDetails%5B25%5D.TrimStart(%22%20Export%20status%3A%20%22)%0A%20%20%20%20Write-Host%20-NoNewline%20%22%20.%22%0A%7D%0AWrite-Host%20%22Download%20Complete!%22%0Apause%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20nice%20part%20about%20this%20is%20the%20unified%20export%20tool%20includes%20it's%20own%20wait%20loop%20that%20checks%20the%20status%20of%20the%20export%2C%20so%20you%20don't%20have%20to%20create%20your%20own%20and%20worry%20about%20credential%20timeout%2C%20etc.%20Thanks%20to%20this%2C%20you%20can%20kick%20off%20the%20download%20and%20move%20on%20to%20other%20tasks%20in%20your%20off-boarding%20script.%3C%2FP%3E%3CP%3EIn%20production%2C%20I've%20written%20this%20to%20execute%20the%20download%20on%20a%20separate%20terminal%20using%20Invoke-Command%20and%20email%20the%20team%20a%20transcript%20when%20the%20download's%20done.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EDrawbacks%3A%3C%2FP%3E%3CP%3EThe%20only%20way%20you%20know%20it's%20running%20is%20the%20process%20shows%20up%20in%20task%20manager.%3C%2FP%3E%3CP%3EThe%20only%20way%20you%20know%20it's%20done%20is%20it's%20not%20in%20task%20manager.%20We%20can%20estimate%20how%20far%20along%20it%20is%2C%20but%20it%20isn't%20perfectly%20accurate.%20You%20definitely%20want%20to%20rely%20on%20the%20trace%20files%20to%20know%20if%20everything%20went%20OK.%3C%2FP%3E%3CP%3EIf%20the%20export%20gets%20stopped%20for%20some%20reason%20(lost%20internet%2C%20restart%20due%20to%20windows%20updates%2C%20etc.)%20it%20does%20not%20resume%20the%20download%20when%20started%20again.%20I%20haven't%20been%20able%20to%20figure%20out%20how%20to%20get%20that%20to%20work.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAnyways%2C%20I%20wanted%20to%20give%20back%20to%20the%20thread%20that%20helped%20me%20get%20this%20far.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1477425%22%20slang%3D%22en-US%22%3ERe%3A%20Export%20to%20PST%20via%20Powershell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1477425%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F147200%22%20target%3D%22_blank%22%3E%40Jonathon%20Chupinsky%3C%2FA%3E%26nbsp%3B%20Thank%20you%20for%20sharing%20the%20powershell%20code.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20got%20an%20error%20when%20started%20to%20the%20export.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20the%20trace.log%20I%20got%20this%20error%3A%3C%2FP%3E%3CP%3E%5B5%5D%5BInformation%5D%3A%20Start%20result%20recorder%20loop.%3CBR%20%2F%3E%5B1%5D%5BError%5D%3A%20Fatal%20error%20happened.%20System.UnauthorizedAccessException%3A%20Access%20to%20the%20path%20'.%5Cx86'%20is%20denied.%3CBR%20%2F%3Eat%20System.IO.__Error.WinIOError(Int32%20errorCode%2C%20String%20maybeFullPath)%3CBR%20%2F%3Eat%20System.IO.Directory.InternalCreateDirectory(String%20fullPath%2C%20String%20path%2C%20Object%20dirSecurityObj%2C%20Boolean%20checkHost)%3CBR%20%2F%3Eat%20System.IO.Directory.InternalCreateDirectoryHelper(String%20path%2C%20Boolean%20checkHost)%3CBR%20%2F%3Eat%20Microsoft.Office.Client.Discovery.UnifiedExport.Engine.Lite.LiteExportEngine.LoadDBBinaries()%3CBR%20%2F%3Eat%20Microsoft.Office.Client.Discovery.UnifiedExport.Engine.Lite.LiteExportEngine.%3CSERVERJOBMONITORLOOP%3Ed__7.MoveNext()%3CBR%20%2F%3E---%20End%20of%20stack%20trace%20from%20previous%20location%20where%20exception%20was%20thrown%20---%3CBR%20%2F%3Eat%20System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()%3CBR%20%2F%3Eat%20System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task%20task)%3CBR%20%2F%3Eat%20Microsoft.Office.Client.Discovery.UnifiedExport.Engine.Lite.LiteExportEngine.%3CEXECUTE%3Ed__4.MoveNext()%3CBR%20%2F%3E%5B1%5D%5BInformation%5D%3A%20Start%20to%20cancel%20the%20export.%3C%2FEXECUTE%3E%3C%2FSERVERJOBMONITORLOOP%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EDo%20you%20know%20where%20the%20folder%20'.%5Cx86'%20is%20and%20how%20to%20set%20the%20permission%20of%20this%20folder%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1477452%22%20slang%3D%22en-US%22%3ERe%3A%20Export%20to%20PST%20via%20Powershell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1477452%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F147200%22%20target%3D%22_blank%22%3E%40Jonathon%20Chupinsky%3C%2FA%3E%26nbsp%3BThank%20you%20for%20sharing%20your%20code.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20get%20a%20problem%20when%20I%20started%20to%20export%20result.%3C%2FP%3E%3CP%3EFrom%20the%20trace.log%20file%20I%20got%20the%20error%3A%3C%2FP%3E%3CP%3EFatal%20error%20happened.%20System.UnauthorizedAccessException%3A%20Access%20to%20the%20path%20'.%5Cx86'%20is%20denied.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAfter%20that%2C%20the%20export%20process%20has%20been%20cancelled.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EDo%20you%20know%20where%20is%20the%20folder%20'.%5Cx86'%20and%20how%20can%20I%20set%20the%20permission%20of%20that%20folder%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1477845%22%20slang%3D%22en-US%22%3ERe%3A%20Export%20to%20PST%20via%20Powershell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1477845%22%20slang%3D%22en-US%22%3E%3CP%3EI%20finally%20found%20the%20reason.%20The%20script%20should%20be%20run%20by%20Powershell%20Administrator%20!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1586226%22%20slang%3D%22en-US%22%3ERe%3A%20Export%20to%20PST%20via%20Powershell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1586226%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F147200%22%20target%3D%22_blank%22%3E%40Jonathon%20Chupinsky%3C%2FA%3E%26nbsp%3B%3CBR%20%2F%3E%3CBR%20%2F%3EI%20am%20curious%20to%20know%20if%20this%20capability%20is%20available%20now%20since%20most%20of%20the%20conversation%20was%20about%20a%20year%20ago.%20I%20am%20also%20needing%20to%20automate%20the%20whole%20process%20via%20a%20script%20but%20it%20looks%20like%20the%20last%20piece%20of%20downloading%20the%20pst%20file%20is%20still%20a%20manual%20process%20from%20the%20GUI%3F%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks!%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1586818%22%20slang%3D%22en-US%22%3ERe%3A%20Export%20to%20PST%20via%20Powershell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1586818%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F758218%22%20target%3D%22_blank%22%3E%40Riftsan%3C%2FA%3E%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYes%2C%20everything%20still%20works%2C%20and%20I%20edited%20my%20original%20post%20a%20few%20months%20ago%20to%20include%20improvements.%3C%2FP%3E%3CP%3EThe%20actual%20downloading%20of%20the%20PST%20does%20require%20Microsoft's%20ClickOnce%20%22Universal%20Export%20Tool%22.%3C%2FP%3E%3CP%3EThe%20script%20includes%20code%20to%20automatically%20download%20the%20tool%20if%20it's%20not%20already%20on%20your%20computer%2C%20and%20download%20the%20PST%20without%20having%20to%20interact%20with%20the%20GUI.%3C%2FP%3E%3CP%3EThe%20only%20issues%20at%20this%20point%20are%20that%20we%20can't%20pull%20real%20stats%20from%20the%20local%20application%2C%20so%20we%20have%20to%20poll%20server-side%20stats%20to%20estimate%20how%20far%20along%20the%20download%20is%2C%20and%20you%20can't%20resume%20a%20download%20if%20it's%20been%20interrupted.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Deleted
Not applicable

I am continually expanding on my offboarding process within Orchestrator. I decided to add the export of the email so that all that has to be done is go to the Content search and download it (unless someone knows how to do that as well...). My addition works, however, instead of creating a single PST file, I end up getting the actual folders with individual email in message file format. I have tried what is correct per everything I could find (honestly, not a lot of detail on the subject). The current single line in question is:

New-ComplianceSearchAction -SearchName $SearchName -Export -ArchiveFormat PerUserPST -EnableDedupe $true 

I have tried different values for -ArchiveFormat including leaving it completely off since a single pst per user is supposed to be the default.

 

 

I will include the entire part of the script responsible for the full function in case it is supposed to be declared somewhere else (but I haven't found anything).

# Create Compliance Search - Export Email

$SearchName = "Export - " + $term.Name
New-ComplianceSearch -ExchangeLocation $term365.UserPrincipalName -Name $SearchName

# Start Compliance Search and wait to complete

Start-ComplianceSearch $SearchName
do
    {
        Start-Sleep -s 5
        $complianceSearch = Get-ComplianceSearch $SearchName
    }
while ($complianceSearch.Status -ne 'Completed')

# Create Compliance Search in exportable format
New-ComplianceSearchAction -SearchName $SearchName -Export -ArchiveFormat PerUserPST -EnableDedupe $true 
$ExportName = $SearchName + "_Export"

#Wait for Export to complete
do
    {
        Start-Sleep -s 5
        $complete = Get-ComplianceSearchAction -Identity $ExportName
    }
while ($complete.Status -ne 'Completed')

Any help would be appreciated!

 

37 Replies
Highlighted

OK. Then it's time to log a support call with Microsoft. 

 

I too have some scripts that I use with searches. When I went to test one to investigate this problem, I also found that I had the wrong permissions and the export parameter wasn't available. After I amended permissions and restarted the PowerShell session, all was well...

Highlighted

I hate to bring back old threads, but it's always nice to find info in threads that show up high on search results.

 

As of today (05/10/2018) the export error still exists. However, swapping back to the "old experience" and using the export results link in the right column still works.

Highlighted

Content search exports are different in the new experience. For one thing, you can no longer use Chrome to export search results because Google has deprecated the feature Microsoft used to download and launch the export app.

 

But I have certainly been able to export information from a content search.

 

Export from a content searchExport from a content searchLeading to:

Export optionsExport options

Isn't that what you see in the new experience?

Highlighted
Yes, that's what I saw before clicking 'Export' (second screen shot). When I clicked it I got the error box that complains about 'failed to find parameter'. I was in IE when failing to export the results in the new UI. Trying a test export to get you a screen shot is failing now though. Apparently after one export went through others are working just fine in both browsers.

As for chrome not working, the ClickOnce extension still works for me. Is it failing for you?
Highlighted

ClickOnce has been deprecated by Google but is still supported in current builds... That's why it still works in the old interface, but it is blocked in the new interface.

So, I've been fighting to automate using powershell to export a PST from Office 365 off and on for a while.

 

AzCopy worked great for Sharepoint/OneDrive exports, but exchange data all came down as ".batch" files, which appear to need further post-processing to collect everything into a PST. Someone better than I might know how to piece them together, but I just moved on.

 

It's a bit of a workaround but here's what I did to automate the PST download.

When you manually download the export using the export tool, the click-once popup downloads their "Unified Export Tool" and populates it with what it needs to get it going. While it's open, you can right-click the process in task manager and click "Open file location". This will take you to the files their tool uses, in your appdata. For me, this location was "%LOCALAPPDATA%\Apps\2.0\QBKH9EZX.XMP\7R4KYC02.WJ7\micr..tool_51a5b647dacf4059_000f.0014_a4b60912e622c727\"

I'm sure Microsoft updates the tool every now and then, so this path may not work indefinitely.

 

Anyways, I just copied everything to a new folder (I don't recommend doing this, i provide an example to find the file automatically in the script below) and ran the "microsoft.office.client.discovery.unifiedexporttool.exe" which returned the parameters that it accepts. Much like AzCopy, it looks for the URL, Token, and a place to drop the files.

 

Here's what I slapped together to automatically download the export from Office 365:

The code below has been edited since this post was created to include improvements to the original code and provide a start to finish example to export and download a PST. If you want to use this as a user off-boarding script you'll need to add those tasks as well. Everyone has their own processes, but Tom Aguero's post below has some good examples too.

 

# Note that I'm not validating any input or providing any adequate error handling.
# This is just an example, you'll need to add these in yourself.

Param(
    [Parameter(Mandatory=$True, HelpMessage='Enter the email address that you want to export')]
    $Mailbox,
    [Parameter(Mandatory=$True, HelpMessage='Enter the URL for the user''s OneDrive here. If you don''t enter one, this will be skipped.')]
    $OneDriveURL,
    [Parameter(Mandatory=$True, HelpMessage='Enter the path where you want to save the PST file. !NO TRAILING BACKSLASH!')]
    $ExportLocation # = ""# you can un-comment the = "" to set a default for this parameter.
)

# Create a search name. You can change this to suit your preference
$SearchName = "$Mailbox PST"

# I'm using the Exchange Online Powershell Module v2. You can install it from an admin session with the following command: Install-Module ExchangeOnlineManagement
Write-Host "Connecting to Exchange Online. Enter your admin credentials in the pop-up (pop-under?) window."
Connect-IPPSSession

Write-Host "Creating compliance search..."
New-ComplianceSearch -Name $SearchName -ExchangeLocation $Mailbox -SharePointLocation $OneDriveURL -AllowNotFoundExchangeLocationsEnabled $true #Create a content search, including the the entire contents of the user's email and onedrive. If you didn't provide a OneDrive URL, or it wasn't valid, it will be ignored.
Write-Host "Starting compliance search..."
Start-ComplianceSearch -Identity $SearchName #Start the search created above
Write-Host "Waiting for compliance search to complete..."
for ($SearchStatus;$SearchStatus -notlike "Completed";){ #Wait then check if the search is complete, loop until complete
    Start-Sleep -s 2
    $SearchStatus = Get-ComplianceSearch $SearchName | Select-Object -ExpandProperty Status #Get the status of the search
    Write-Host -NoNewline "." # Show some sort of status change in the terminal
}
Write-Host "Compliance search is complete!"
Write-Host "Creating export from the search..."
New-ComplianceSearchAction -SearchName $SearchName -Export -Format FxStream -ExchangeArchiveFormat PerUserPst -Scope BothIndexedAndUnindexedItems -EnableDedupe $true -SharePointArchiveFormat IndividualMessage -IncludeSharePointDocumentVersions $true 
Start-Sleep -s 5 # Arbitrarily wait 5 seconds to give microsoft's side time to create the SearchAction before the next commands try to run against it. I /COULD/ do a for loop and check, but it's really not worth it.

# Check if the export tool is installed for the user, and download if not.
While (-Not ((Get-ChildItem -Path $($env:LOCALAPPDATA + "\Apps\2.0\") -Filter microsoft.office.client.discovery.unifiedexporttool.exe -Recurse).FullName | Where-Object{ $_ -notmatch "_none_" } | Select-Object -First 1)){
    Write-Host "Downloading Unified Export Tool ."
    Write-Host "This is installed per-user by the Click-Once installer."
    # Credit to Jos Verlinde for his code in Load-ExchangeMFA in the Powershell Gallery! All I've done is update the manifest url and remove all the comments
    # Ripped from https://www.powershellgallery.com/packages/Load-ExchangeMFA/1.2
    # In case anyone else has any ClickOnce applications they'd like to automate the install for:
    # If you're looking for where to find a manifest URL, once you have run the ClickOnce application at least once on your computer, the url for the application manifest can be found in the Windows Registry at "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Uninstall" (yes, CTR apps are installed per-user).
    # Look through the keys with names that are 16 characters long hex strings. They'll have a string value (REG_SZ) named either "ShortcutAppId" or "UrlUpdateInfo" that contains the URL as the first part of the string.
    $Manifest = "https://complianceclientsdf.blob.core.windows.net/v16/Microsoft.Office.Client.Discovery.UnifiedExportTool.application"
    $ElevatePermissions = $true
    Try {
        Add-Type -AssemblyName System.Deployment
        Write-Host "Starting installation of ClickOnce Application $Manifest "
        $RemoteURI = [URI]::New( $Manifest , [UriKind]::Absolute)
        if (-not  $Manifest){
            throw "Invalid ConnectionUri parameter '$ConnectionUri'"
        }
        $HostingManager = New-Object System.Deployment.Application.InPlaceHostingManager -ArgumentList $RemoteURI , $False
        Register-ObjectEvent -InputObject $HostingManager -EventName GetManifestCompleted -Action { 
            new-event -SourceIdentifier "ManifestDownloadComplete"
        } | Out-Null
        Register-ObjectEvent -InputObject $HostingManager -EventName DownloadApplicationCompleted -Action { 
            new-event -SourceIdentifier "DownloadApplicationCompleted"
        } | Out-Null
        $HostingManager.GetManifestAsync()
        $event = Wait-Event -SourceIdentifier "ManifestDownloadComplete" -Timeout 15
        if ($event ) {
            $event | Remove-Event
            Write-Host "ClickOnce Manifest Download Completed"
            $HostingManager.AssertApplicationRequirements($ElevatePermissions)
            $HostingManager.DownloadApplicationAsync()
            $event = Wait-Event -SourceIdentifier "DownloadApplicationCompleted" -Timeout 60
            if ($event ) {
                $event | Remove-Event
                Write-Host "ClickOnce Application Download Completed"
            }
            else {
                Write-error "ClickOnce Application Download did not complete in time (60s)"
            }
        }
        else {
            Write-error "ClickOnce Manifest Download did not complete in time (15s)"
        }
    }
    finally {
        Get-EventSubscriber|? {$_.SourceObject.ToString() -eq 'System.Deployment.Application.InPlaceHostingManager'} | Unregister-Event
    }
}

# Find the Unified Export Tool's location and create a variable for it
$ExportExe = ((Get-ChildItem -Path $($env:LOCALAPPDATA + "\Apps\2.0\") -Filter microsoft.office.client.discovery.unifiedexporttool.exe -Recurse).FullName | Where-Object{ $_ -notmatch "_none_" } | Select-Object -First 1)

# Gather the URL and Token from the export in order to start the download
# We only need the ContainerURL and SAS Token at a minimum but we're also pulling others to help with tracking the status of the export.
$ExportName = $SearchName + "_Export"
$ExportDetails = Get-ComplianceSearchAction -Identity $ExportName -IncludeCredential -Details # Get details for the export action
# This method of splitting the Container URL and Token from $ExportDetails is thanks to schmeckendeugler from reddit: https://www.reddit.com/r/PowerShell/comments/ba4fpu/automated_download_of_o365_inbox_archive/
# I was using Convert-FromString before, which was slow and terrible. His way is MUCH better.
$ExportDetails = $ExportDetails.Results.split(";")
$ExportContainerUrl = $ExportDetails[0].trimStart("Container url: ")
$ExportSasToken = $ExportDetails[1].trimStart(" SAS token: ")
$ExportEstSize = ($ExportDetails[18].TrimStart(" Total estimated bytes: ") -as [double])
$ExportTransferred = ($ExportDetails[20].TrimStart(" Total transferred bytes: ") -as [double])
$ExportProgress = $ExportDetails[22].TrimStart(" Progress: ").TrimEnd("%")
$ExportStatus = $ExportDetails[25].TrimStart(" Export status: ")

# Download the exported files from Office 365
Write-Host "Initiating download"
Write-Host "Saving export to: " + $ExportLocation
$Arguments = "-name ""$SearchName""","-source ""$ExportContainerUrl""","-key ""$ExportSasToken""","-dest ""$ExportLocation""","-trace true"
Start-Process -FilePath "$ExportExe" -ArgumentList $Arguments

# The export is now downloading in the background. You can find it in task manager. Let's monitor the progress.
# If you want to use this as part of a user offboarding script, add your edits above here - Exports can take a lot of time...
# You can even comment this entire section and exit the script if you dont feel the need to monitor the download, it will keep downloading in the background even without the script running.
# This is only monitoring if the process exists, which means if you run multiple exports, this will stay running until they all complete.
# We could possibly utilize sysinternals handle.exe to identify the PID of the process writing to the $Exportlocation and monitor for that specifically, but I'm trying to limit external applications in this example script.
#
# Just an FYI, the export progress is how much data Microsoft has copied into PSTs from the compliance search, not how much the export tool has downloaded.
# We only know the actual size of the download after the $ExportProgress is 100% and $ExportStatus is Completed
# The actual final size of the download is then reflected in $ExportTransferred. Even then, our progress is still a bit inaccurate due to the extra log and temp files created locally, which will probably cause the progress to show over 100%
# We could make this a bit more accurate by just collecting the size of PSTs and files under the OneDrive folder, but I think this brings us close enough for most situations.
while(Get-Process microsoft.office.client.discovery.unifiedexporttool -ErrorAction SilentlyContinue){
    $Downloaded = Get-ChildItem $ExportLocation\$SearchName -Recurse | Measure-Object -Property Length -Sum | Select-Object -ExpandProperty Sum
    Write-Progress -Id 1 -Activity "Export in Progress" -Status "Complete..." -PercentComplete $ExportProgress
    if ("Completed" -notlike $ExportStatus){Write-Progress -Id 2 -Activity "Download in Progress" -Status "Estimated Complete..." -PercentComplete ($Downloaded/$ExportEstSize*100) -CurrentOperation "$Downloaded/$ExportEstSize bytes downloaded."}
    else {Write-Progress -Id 2 -Activity "Download in Progress" -Status "Complete..." -PercentComplete ($Downloaded/$ExportEstSize*100) -CurrentOperation "$Downloaded/$ExportTransferred bytes downloaded."}
    Start-Sleep 60
    $ExportDetails = Get-ComplianceSearchAction -Identity $ExportName -IncludeCredential -Details # Get details for the export action
    $ExportDetails = $ExportDetails.Results.split(";")
    $ExportEstSize = ($ExportDetails[18].TrimStart(" Total estimated bytes: ") -as [double])
    $ExportTransferred = ($ExportDetails[20].TrimStart(" Total transferred bytes: ") -as [double])
    $ExportProgress = $ExportDetails[22].TrimStart(" Progress: ").TrimEnd("%")
    $ExportStatus = $ExportDetails[25].TrimStart(" Export status: ")
    Write-Host -NoNewline " ."
}
Write-Host "Download Complete!"
pause

 

The nice part about this is the unified export tool includes it's own wait loop that checks the status of the export, so you don't have to create your own and worry about credential timeout, etc. Thanks to this, you can kick off the download and move on to other tasks in your off-boarding script.

In production, I've written this to execute the download on a separate terminal using Invoke-Command and email the team a transcript when the download's done.

 

Drawbacks:

The only way you know it's running is the process shows up in task manager.

The only way you know it's done is it's not in task manager. We can estimate how far along it is, but it isn't perfectly accurate. You definitely want to rely on the trace files to know if everything went OK.

If the export gets stopped for some reason (lost internet, restart due to windows updates, etc.) it does not resume the download when started again. I haven't been able to figure out how to get that to work.

 

Anyways, I wanted to give back to the thread that helped me get this far.

Highlighted

Is this still working for you? Have you made any changes/improvements since you posted this?

 

How'd you get the container URL?

 

Thanks!

Highlighted

Yes, this still worked quite well as of a week ago. I can only see this breaking if Microsoft changes the format of the "Results" property of the content search or splits it into separate properties of their own.

I haven't made any real improvements to it, but this reminds me that I should probably combine my code with Brad's so that there's a minimally functional example. I'll edit my previous post at some time for that.

 

The container URL comes from the "$exportdetails =" line.

It first gets the compliance search, selects the Results property that contains the container URL, then parses the URL and token from the property using the $exporttemplate

The results property is just one giant string of information, instead of separate properties of their own, so parsing it with Convert-FromString was the easiest way I could think of to get those properties.

 

Convert-FromString requires a template consisting of at least two lines of data, formatted so that it knows what you're looking to parse. The data in $exporttemplate is just two of our old searches, modified with the parsing tags. Sorry if that's not incredibly clear.

Highlighted

Awesome, I got it working and I figured out a way to monitor the process along with the percent complete. Sorry, I'm not sure how to do the fancy formatting for this post.

 

#Do while microsoft.office.client.discovery.unifiedexporttool.exe running
$started = $false
Do { $status = Get-Process microsoft.office.client.discovery.unifiedexporttool -ErrorAction SilentlyContinue
If (!($status)) {

Write-Host 'Waiting for process to start' ; Start-Sleep -Seconds 5 }

Else {

Write-Host 'Process has started' ; $started = $true

}

}Until ( $started )  

 

Do{

$ProcessesFound = Get-Process | ? {$_.Name -like "*unifiedexporttool*"}
If ($ProcessesFound) { $

Progress = get-ComplianceSearchAction -Identity $exportname -IncludeCredential -Details | select -ExpandProperty Results | ConvertFrom-String -TemplateContent $exporttemplate | %{$_.Progress}
Write-Host "Export still downloading, progress is $Progress, waiting 60 seconds"
Start-Sleep -s 60

}

}Until (!$ProcessesFound)

Highlighted

Oh nice! I forgot I parsed that and didn't even think about polling the server-side progress.

The only thing I can see being an issue is if it's a very large export, or you have a slow connection, your session with office 365 might timeout before it's done.

I'll try adding it to our implementation and see if I run into any problems.

 

Are you logging the entire session with a transcript? If not, I'd recommend writing the progress to a file so you can quickly check if it finished or not, in case your computer restarts for windows updates or something while you're not looking. "Write-Output $Progress | Out-File" is quick and easy, but you might want to include a timestamp as well.

Highlighted

@Tom Aguero Can you share the whole script to download pst physically from EXO mailboxes

Highlighted

@Edgar Guerrero Sure, I think I sanitized it

 

#region Connect to all the things
#Test O365 Connection
If($Null -eq $O365Cred){
$O365Cred = $Host.ui.PromptForCredential("","Enter your OFFICE 365 admin creds","ENTER YOUR ACCOUNT NAME HERE","")
}

Try{Get-O365Mailbox aguerot -ErrorAction Stop > $Null}
Catch{
$O365Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $O365Cred -Authentication Basic -AllowRedirection
Import-PSSession $O365Session –Prefix o365
}

Try{Get-MsolUser -UserPrincipalName ENTER TEST USER HERE -ErrorAction Stop > $Null}
Catch{Connect-MsolService -Credential $O365Cred}

Try{Get-ComplianceSearch > $Null}
Catch{
#Get login credentials
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.compliance.protection.outlook.com/powershell-liveid -Credential $O365Cred -Authentication Basic -AllowRedirection
Import-PSSession $Session -AllowClobber -DisableNameChecking
}
#endregion

#Get User Info
$User = Read-host "Enter user name"

$Logfile = "PATH TO LOG FILE\$User.txt"

Function LogWrite
{
Param ([string]$logstring)
Write-Host $LogString
Add-content $Logfile -value $logstring
}
$Date = Get-Date -Format "MM/dd/yyyy"
LogWrite $Date
LogWrite " "
LogWrite "Username: $User"

#Begin Compliance Search
$UPN = Get-ADUser $User | ForEach-Object{$_.UserPrincipalName}
$SearchName = $User + "_Termed"
New-ComplianceSearch -Name $SearchName -ExchangeLocation $UPN
Start-ComplianceSearch $SearchName
Logwrite " "
LogWrite "Compliance search $SearchName started"
Do{
$complianceSearch = Get-ComplianceSearch $SearchName | ForEach-Object{$_.Status}
Write-Host "Compliance Search in Progress"
Start-Sleep -s 30
}
While ($complianceSearch -ne 'Completed')
$Size = Get-ComplianceSearch $SearchName | ForEach-Object{$_.Size}
$Size = $Size / 1048576 | Out-String
$Size = $Size.SubString(0,6)

# Create Compliance Search in exportable format
New-ComplianceSearchAction -SearchName $SearchName -EnableDedupe $true -Export -Format FxStream -ArchiveFormat PerUserPST > $Null

#Wait for Export to complete
$ExportName = $SearchName + "_Export"
Start-Sleep -s 20
do{
$SearchAction = Get-ComplianceSearchAction -Identity $ExportName | Select-Object Status,JobProgress
$Status = $SearchAction.Status
$ExportProgress = $SearchAction.JobProgress
Write-Host "Export in progress, $ExportProgress complete"
If($Status -ne "Completed"){
Start-Sleep -s 60
}
}
while ($Status -ne 'Completed')

LogWrite "Compliance search completed"

$exportlocation = "C:\pst" #enter the path to your export here !NO TRAILING BACKSLASH!
$exportexe = "\UnifiedExportTool\microsoft.office.client.discovery.unifiedexporttool.exe" #path to your microsoft.office.client.discovery.unifiedexporttool.exe file. Usually found somewhere in ForEach-ObjectLOCALAPPDATAForEach-Object\Apps\2.0\

# Gather the URL and Token from the export in order to start the download
#We only need the ContainerURL and SAS Token but I parsed some other fields as well while working with AzCopy
#The Container URL and Token in the following template has been altered to protect the innocent:
$exporttemplate = @'
Container url: {ContainerURL*:https://xicnediscnam.blob.core.windows.net/da3fecb0-4ed4-447e-0315-08d5adad8a5a}; SAS token: {SASToken:?sv=2014-02-14&sr=c&si=eDiscoveryBlobPolicy9ForEach-Object7C0&sig=RACMSyH6Cf0k4EP2wZSoAa0QrhKaV38Oa9ciHv5Y8MkForEach-Object3D}; Scenario: General; Scope: BothIndexedAndUnindexedItems; Scope details: AllUnindexed; Max unindexed size: 0; File type exclusions for unindexed: <null>; Total sources: 2; Exchange item format: Msg; Exchange archive format: IndividualMessage; SharePoint archive format: SingleZip; Include SharePoint versions: True; Enable dedupe: EnableDedupe:True; Reference action: "<null>"; Region: ; Started sources: StartedSources:3; Succeeded sources: SucceededSources:1; Failed sources: 0; Total estimated bytes: 12,791,334,934; Total estimated items: 143,729; Total transferred bytes: {TotalTransferredBytes:7,706,378,435}; Total transferred items: {TotalTransferredItems:71,412}; Progress: {Progress:49.69 ForEach-Object}; Completed time: ; Duration: 00:50:43.9321895; Export status: {ExportStatus:DistributionCompleted}
Container url: {ContainerURL*:https://zgrbediscnam.blob.core.windows.net/5c21f7c7-42a2-4e24-9e69-08d5acf316f5}; SAS token: {SASToken:?sv=2014-02-14&sr=c&si=eDiscoveryBlobPolicy9ForEach-Object7C0&sig=F6ycaX5eWcRBCS1Z5nfoTKJWTrHkAciqbYRP5ForEach-Object2FhsUOoForEach-Object3D}; Scenario: General; Scope: BothIndexedAndUnindexedItems; Scope details: AllUnindexed; Max unindexed size: 0; File type exclusions for unindexed: <null>; Total sources: 1; Exchange item format: FxStream; Exchange archive format: PerUserPst; SharePoint archive format: IndividualMessage; Include SharePoint versions: True; Enable dedupe: True; Reference action: "<null>"; Region: ; Started sources: 2; Succeeded sources: 2; Failed sources: 0; Total estimated bytes: 69,952,559,461; Total estimated items: 107,707; Total transferred bytes: {TotalTransferredBytes:70,847,990,489}; Total transferred items: {TotalTransferredItems:100,808}; Progress: {Progress:93.59 ForEach-Object}; Completed time: 4/27/2018 11:45:46 PM; Duration: 04:31:21.1593737; Export status: {ExportStatus:Completed}
'@
$exportdetails = Get-ComplianceSearchAction -Identity $exportname -IncludeCredential -Details | Select-Object -ExpandProperty Results | ConvertFrom-String -TemplateContent $exporttemplate
$exportdetails
$exportcontainerurl = $exportdetails.ContainerURL
$exportsastoken = $exportdetails.SASToken

# Download the exported files from Office 365
Write-Host "Compliance Search Size:" $Size
LogWrite "Initiating download"
LogWrite "Saving export to: $exportlocation"
$arguments = "-name ""$searchname""","-source ""$exportcontainerurl""","-key ""$exportsastoken""","-dest ""$exportlocation""","-trace true"
Start-Process -FilePath "$exportexe" -ArgumentList $arguments

#Do while microsoft.office.client.discovery.unifiedexporttool.exe running
$started = $false
Do {
$status = Get-Process microsoft.office.client.discovery.unifiedexporttool -ErrorAction SilentlyContinue
If (!($status)) {
Write-Host 'Waiting for process to start' ; Start-Sleep -Seconds 5
}
Else {
Write-Host 'Process has started' ; $started = $true
}
}
Until ( $started )

Do{
$Finished = $False
Write-host "Sleeping 300 seconds"
Start-Sleep -s 300
$DownloadSize = Get-Childitem "C:\pst" -recurse -include *.pst | ForEach-Object{$_.Length}
$DownloadSize = $DownloadSize / 1048576 | Out-String
$DownloadSize = $DownloadSize.SubString(0,6)
Write-Host " "
Write-Host "Compliance Search Size:" $Size
Write-Host "Downloaded Size:" $DownloadSize
Write-Host " "
<## Commenting this out to test performance
$ProcessesFound = Get-Process | ? {$_.Name -like "*unifiedexporttool*"}
Write-Host "Process still running"
 
If ($ProcessesFound) {
$Progress = get-ComplianceSearchAction -Identity $exportname -IncludeCredential -Details | Select-Object -ExpandProperty Results | ConvertFrom-String -TemplateContent $exporttemplate | ForEach-Object{$_.Progress}
Write-Host "Export still downloading, progress is $Progress, waiting 300 seconds"
Start-Sleep -s 300
}
#>
If($DownloadSize -ge $Size){
$status = Get-Process microsoft.office.client.discovery.unifiedexporttool -ErrorAction SilentlyContinue
If (!($status)) {
Write-Host "Download has finished"
$Finished = $True
}
}
}Until ($Finished -eq $True)

$DownloadSize = Get-Childitem "C:\pst" -recurse -include *.pst | ForEach-Object{$_.Length}
$DownloadSize = $DownloadSize / 1048576 | Out-String
$DownloadSize = $DownloadSize.SubString(0,6)

Write-Host " "
Write-Host "Compliance Search Size:" $Size
Write-Host "Downloaded Size:" $DownloadSize
Write-Host " "

#Read-Host "Pausing script until you verify download. Seriously. If the download isn't done this gets really bad. You sure you're ready? Press enter to continue"

LogWrite "PST exported & downloaded"

#Remove compliance search & export
$ExportName = $SearchName + "_Export"
Remove-ComplianceSearchAction -Identity $ExportName -Confirm:$False
Remove-ComplianceSearch $SearchName -Confirm:$False
If($?){Write-Host "Compliance search & export removed"}

#Get & Remove O365 licenses
$UPN2 = Get-ADUser -Identity $User | ForEach-Object{$_.UserPrincipalName}
$MSOLUser = Get-MsolUser -UserPrincipalName $UPN2 -ErrorAction SilentlyContinue

#$IsLicensed = $MSOLUser.IsLicensed
$Licenses = $MSOLUser.Licenses[0].AccountSkuId

Set-MsolUserLicense -UserPrincipalName $UPN2 -RemoveLicenses $Licenses
If($?){Write-Host "$User $Licenses removed"}

#Move to Disabled Accts OU
Get-AdUser $User | Move-AdObject -TargetPath "" #Moves to an OU that doesnt sync to O365
LogWrite "$User account has been moved to Disabled Accts OU"

#Run DirSync on Azure AD Connect sync server
Invoke-Command -Computername "" -ScriptBlock {C:\DirSync-ForceDelta.ps1} #Runs an Azure AD Connect Directory sync on a remote server

#Move PST for upload
Get-Childitem "C:\pst" -recurse -include *.pst | Move-Item -Destination "C:\pst"

#Upload mailbox to Azure
Write-Host "Uploading to Azure"

Start-Process "Disable User Process\LaunchCmd-Custom.cmd" #Customized Azure Storage AZ copy upload script

#Confirm upload to finished
write-host " "
$confirmation = Read-Host "Did Azure upload complete successfully? You need to enter y here"
if ($confirmation -eq 'y'){
#Delete pst
Remove-Item "C:\pst\*" -Recurse -Confirm:$False
If($?){Write-host " "
Write-Host "PST Deleted"}
}
Also, here is the AZ copy script, you need to get your own key and destination info. I honestly forget how to get that.
@echo off
title Microsoft Azure Storage tools
set LaunchCmdFolder="C:\Program Files (x86)\Microsoft SDKs\Azure\AzCopy"
set PATH=%PATH%;%LaunchCmdFolder%AzCopy

Set azcopy="C:\Program Files (x86)\Microsoft SDKs\Azure\AzCopy\AzCopy.exe"
Set source="C:\pst"
Set dest=
set key=

%azcopy% /source:%source% /Dest:%dest% /DestKey:%key% /Pattern:*.pst /S /V:C:\AZCopy.log

Pause
Highlighted

Hi, @Tom Aguero Thanks for the help so far.

I am not able to start the export.

From the tracert file i got this message:
Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Office.Client.Discovery.UnifiedExport, Version=15.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

 

Do I need to do something with the Microsoft.Office.Client.Discovery.UnifiedExportTool.application file or should it work with Container url and SAS token?

 

I also fund this (he has stolen some part from you). Still no luck.
https://www.reddit.com/r/PowerShell/comments/ba4fpu/automated_download_of_o365_inbox_archive/

 

Any help is appreciated

Highlighted

Hi @Powershell_mannen69 

It looks like the export tool can't load one of it's dependency files. Did you copy the exe out of your profile folder without all the rest of the files? And, are you using Tom Aguero's code? If so, try replacing:

 

 

$exportexe = "\UnifiedExportTool\microsoft.office.client.discovery.unifiedexporttool.exe"

 

 

with:

 

 

$exportexe = ((Get-ChildItem -Path $($env:LOCALAPPDATA + "\Apps\2.0\") -Filter microsoft.office.client.discovery.unifiedexporttool.exe -Recurse).FullName | Where-Object{ $_ -notmatch "_none_" } | Select-Object -First 1)

 

 

and see if that helps?

 

This should find the exe within your profile, without having to copy the file or use any static paths, which should help if you have multiple people that may run the script.

 

Also, thanks for the Reddit link, I like their way of pulling the URL and token much better! I'll have to try it out on the next run of the script.

 

 

Additionally, If anyone wants to automate downloading the unified export tool:

# Check if the export tool is installed for the user, and download if not.
While (-Not ((Get-ChildItem -Path $($env:LOCALAPPDATA + "\Apps\2.0\") -Filter microsoft.office.client.discovery.unifiedexporttool.exe -Recurse).FullName | Where-Object{ $_ -notmatch "_none_" } | Select-Object -First 1)){
    Write-Host "Downloading Unified Export Tool ."
    Write-Host "This is installed per-user by the Click-Once installer."
    # Credit to Jos Verlinde for his code in Load-ExchangeMFA in the Powershell Gallery! All I've done is update the manifest url and remove all the comments
    # Ripped from https://www.powershellgallery.com/packages/Load-ExchangeMFA/1.2
    # In case anyone else has any ClickOnce applications they'd like to automate the install for:
    # If you're looking for where to find a manifest URL, once you have run the ClickOnce application at least once on your computer, the url for the application manifest can be found in the Windows Registry at "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Uninstall" (yes, CTR apps are installed per-user).
    # Look through the keys with names that are 16 characters long hex strings. They'll have a string value (REG_SZ) named either "ShortcutAppId" or "UrlUpdateInfo" that contains the URL as the first part of the string.
    $Manifest = "https://complianceclientsdf.blob.core.windows.net/v16/Microsoft.Office.Client.Discovery.UnifiedExportTool.application"
    $ElevatePermissions = $true
    Try {
        Add-Type -AssemblyName System.Deployment
        Write-Host "Starting installation of ClickOnce Application $Manifest "
        $RemoteURI = [URI]::New( $Manifest , [UriKind]::Absolute)
        if (-not  $Manifest){
            throw "Invalid ConnectionUri parameter '$ConnectionUri'"
        }
        $HostingManager = New-Object System.Deployment.Application.InPlaceHostingManager -ArgumentList $RemoteURI , $False
        Register-ObjectEvent -InputObject $HostingManager -EventName GetManifestCompleted -Action { 
            new-event -SourceIdentifier "ManifestDownloadComplete"
        } | Out-Null
        Register-ObjectEvent -InputObject $HostingManager -EventName DownloadApplicationCompleted -Action { 
            new-event -SourceIdentifier "DownloadApplicationCompleted"
        } | Out-Null
        $HostingManager.GetManifestAsync()
        $event = Wait-Event -SourceIdentifier "ManifestDownloadComplete" -Timeout 15
        if ($event ) {
            $event | Remove-Event
            Write-Host "ClickOnce Manifest Download Completed"
            $HostingManager.AssertApplicationRequirements($ElevatePermissions)
            $HostingManager.DownloadApplicationAsync()
            $event = Wait-Event -SourceIdentifier "DownloadApplicationCompleted" -Timeout 60
            if ($event ) {
                $event | Remove-Event
                Write-Host "ClickOnce Application Download Completed"
            }
            else {
                Write-error "ClickOnce Application Download did not complete in time (60s)"
            }
        }
        else {
            Write-error "ClickOnce Manifest Download did not complete in time (15s)"
        }
    }
    finally {
        Get-EventSubscriber|? {$_.SourceObject.ToString() -eq 'System.Deployment.Application.InPlaceHostingManager'} | Unregister-Event
    }
}

$exportexe = ((Get-ChildItem -Path $($env:LOCALAPPDATA + "\Apps\2.0\") -Filter microsoft.office.client.discovery.unifiedexporttool.exe -Recurse).FullName | Where-Object{ $_ -notmatch "_none_" } | Select-Object -First 1)

 

Highlighted

Hi @Jonathon Chupinsky Thank you for sharing your code.

 

I get a problem when I started to export result.

From the trace.log file I got the error:

Fatal error happened. System.UnauthorizedAccessException: Access to the path '.\x86' is denied.

 

After that, the export process has been cancelled.

 

Do you know where is the folder '.\x86' and how can I set the permission of that folder?

 

Thanks

 

 

Highlighted

I finally found the reason. The script should be run by Powershell Administrator !

Highlighted

@Jonathon Chupinsky 

I am curious to know if this capability is available now since most of the conversation was about a year ago. I am also needing to automate the whole process via a script but it looks like the last piece of downloading the pst file is still a manual process from the GUI? 

 

Thanks! 

Highlighted

Hi @Riftsan,

 

Yes, everything still works, and I edited my original post a few months ago to include improvements.

The actual downloading of the PST does require Microsoft's ClickOnce "Universal Export Tool".

The script includes code to automatically download the tool if it's not already on your computer, and download the PST without having to interact with the GUI.

The only issues at this point are that we can't pull real stats from the local application, so we have to poll server-side stats to estimate how far along the download is, and you can't resume a download if it's been interrupted.