1
- # Get Outlook object
2
- $Outlook = New-Object - ComObject Outlook.Application
3
-
4
- # Get Inbox
5
- $Namespace = $Outlook.GetNamespace (' MAPI' )
6
- $Inbox = $Namespace.GetDefaultFolder (6 )
7
-
8
- try {
9
- # Create new Quarantine folder
10
- $Quarantine = $Inbox.Folders.Add (' Quarantine' )
11
- } catch {
12
- # Get existing Quarantine folder
1
+ begin { Start-Transcript $env: TEMP \olQuarantineEnable.log }
2
+
3
+ process {
4
+ # Get Outlook object
5
+ Add-Type - AssemblyName Microsoft.Office.Interop.Outlook
6
+ $Outlook = New-Object - ComObject Outlook.Application
7
+
8
+ # Get Inbox
9
+ $Namespace = $Outlook.GetNamespace (' MAPI' )
10
+ $Inbox = $Namespace.GetDefaultFolder ([Microsoft.Office.Interop.Outlook.OlDefaultFolders ]::olFolderInbox)
11
+
12
+ try {
13
+ # Create new Quarantine folder
14
+ $Quarantine = $Inbox.Folders.Add (' Quarantine' )
15
+ } catch {
16
+ # Get existing Quarantine folder
17
+ $Quarantine = $Inbox.Folders | Where-Object - Property Name -eq ' Quarantine'
18
+ }
19
+
20
+ # Set the web Url to the Quarantine admin site and set web view as default
21
+ $Quarantine.WebViewURL = ' https://admin.protection.outlook.com/quarantine'
22
+ $Quarantine.WebViewOn = $true
23
+
24
+ # Add Quarantine folder to favorites
25
+ $OutlookModule = $Outlook.ActiveExplorer ().NavigationPane.Modules.Item(' Mail' )
26
+ $Favorites = $OutlookModule.NavigationGroups.Item (' Favorites' )
27
+ $Favorites.NavigationFolders.Add ($Quarantine )
28
+
29
+ # Validate settings
13
30
$Quarantine = $Inbox.Folders | Where-Object - Property Name -eq ' Quarantine'
14
- }
15
-
16
- # Set the web Url to the Quarantine admin site and set web view as default
17
- $Quarantine.WebViewURL = ' https://admin.protection.outlook.com/quarantine'
18
- $Quarantine.WebViewOn = $true
19
31
20
- # Add Quarantine folder to favorites
21
- $OutlookModule = $Outlook.ActiveExplorer ().NavigationPane.Modules.Item(' Mail' )
22
- $Favorites = $OutlookModule.NavigationGroups.Item (' Favorites' )
23
- $Favorites.NavigationFolders.Add ($Quarantine )
32
+ if ($Quarantine ) {
33
+ if ($Quarantine.WebViewURL -ne ' https://admin.protection.outlook.com/quarantine' ) { exit 996 }
24
34
25
- # Validate settings
26
- $Quarantine = $Inbox.Folders | Where-Object - Property Name -eq ' Quarantine'
35
+ if (-not $Quarantine.WebViewOn ) { exit 997 }
27
36
28
- if ($Quarantine ) {
29
- if ($Quarantine.WebViewURL -ne ' https://admin.protection.outlook.com/quarantine' ) { exit 999 }
37
+ if (-not $Favorites.NavigationFolders.Item ($Quarantine.Name )) { exit 998 }
30
38
31
- if (-not $Quarantine.WebViewOn ) { exit 999 }
32
-
33
- if (-not $Favorites.NavigationFolders.Item ($Quarantine.Name )) { exit 999 }
39
+ exit 0
40
+ } else {
41
+ exit 995
42
+ }
43
+ }
34
44
35
- exit 0
36
- } else {
37
- exit 999
45
+ end {
46
+ # Used as detection method in SCCM
47
+ New-Item - Path ' HKLM:\Software\SMS' - ItemType Key - Force |
48
+ New-ItemProperty - Name olQuarantineEnabled - Value $LASTEXITCODE - PropertyType String - Force
49
+ Stop-Transcript
38
50
}
0 commit comments