From 25894044e0e48ac2993f0cd5ef30f0659fa6187e Mon Sep 17 00:00:00 2001 From: silversword411 Date: Mon, 3 May 2021 18:20:38 -0400 Subject: [PATCH] script library - adding outlook delegated folders --- .../scripts/community_scripts.json | 10 +++ ...Outlook_SentItems_To_Delegated_Folders.ps1 | 61 +++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 scripts/Win_Outlook_SentItems_To_Delegated_Folders.ps1 diff --git a/api/tacticalrmm/scripts/community_scripts.json b/api/tacticalrmm/scripts/community_scripts.json index cc04238e..bde58721 100644 --- a/api/tacticalrmm/scripts/community_scripts.json +++ b/api/tacticalrmm/scripts/community_scripts.json @@ -602,6 +602,16 @@ "shell": "powershell", "category": "TRMM (Win):Other" }, + { + "guid": "e371f1c6-0dd9-44de-824c-a17e1ca4c4ab", + "filename": "Win_Outlook_SentItems_To_Delegated_Folders.ps1", + "submittedBy": "https://github.com/dinger1986", + "name": "Outlook - Delegated folders set for all profiles", + "description": "Uses RunAsUser to setup sent items for the currently logged on user on delegated folders to go into the delegated folders sent for all.", + "shell": "powershell", + "category": "TRMM (Win):Office", + "default_timeout": "90" + }, { "guid": "17040742-184a-4251-8f7b-4a1b0a1f02d1", "filename": "Win_File_Copy_Misc.ps1", diff --git a/scripts/Win_Outlook_SentItems_To_Delegated_Folders.ps1 b/scripts/Win_Outlook_SentItems_To_Delegated_Folders.ps1 new file mode 100644 index 00000000..0b3c0709 --- /dev/null +++ b/scripts/Win_Outlook_SentItems_To_Delegated_Folders.ps1 @@ -0,0 +1,61 @@ +<# +.Synopsis + Outlook - Delegated folders set for all profiles +.DESCRIPTION + Uses RunAsUser to setup sent items for the currently logged on user on delegated folders to go into the delegated folders sent for all. + Applies to Office 2016 and later, modify reg key for older versions of office. + https://docs.microsoft.com/en-us/outlook/troubleshoot/email-management/email-remains-in-the-outbox-when-you-use-the-deleg +.NOTES + v1.0 + Submitted by: https://github.com/dinger1986 +#> + +[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 + +$regpath = HKCU:\Software\Microsoft\Office\16.0\Outlook\Preferences +$regname = DelegateSentItemsStyle +$regvalue = 1 +$regproperty = Dword + + +If (!(test-path '%ProgramData%\Tactical RMM\temp')) { + New-Item -ItemType Directory -Force -Path '%ProgramData%\Tactical RMM\temp' +} + +If (!(test-path C:\TEMP\curpsxpolicy.txt)) { + $curexpolicy = Get-ExecutionPolicy + + ( + echo $curexpolicy + )>"%ProgramData%\Tactical RMM\temp\curpsxpolicy.txt" +} + +Set-ExecutionPolicy -ExecutionPolicy Unrestricted + +if (Get-PackageProvider -Name NuGet) { + Write-Output "NuGet Already Added" +} +else { + Write-Host "Installing NuGet" + Install-PackageProvider -Name NuGet -Force +} + +if (Get-Module -ListAvailable -Name RunAsUser) { + Write-Output "RunAsUser Already Installed" +} +else { + Write-Output "Installing RunAsUser" + Install-Module -Name RunAsUser -Force +} + +Invoke-AsCurrentUser -scriptblock { + New-ItemProperty -Path "$regpath" -Name "$regname" -Value "$regvalue" -PropertyType "$regproperty" +} + +Write-Output "Successfully changed Sent Items for Delegated folders" + +$curpsxpol = Get-Content -Path "%ProgramData%\Tactical RMM\temp\curpsxpolicy.txt"; + +Set-ExecutionPolicy -ExecutionPolicy $curpsxpol + +del "%ProgramData%\Tactical RMM\temp\curpsxpolicy.txt" \ No newline at end of file