diff --git a/Detect_OfficeMgmtCOM.ps1 b/Detect_OfficeMgmtCOM.ps1 index fe011ab..1f4ca06 100644 --- a/Detect_OfficeMgmtCOM.ps1 +++ b/Detect_OfficeMgmtCOM.ps1 @@ -4,15 +4,20 @@ $Type = "DWORD" $Value = 0 Try { - $Registry = Get-ItemProperty -Path $Path -Name $Name -ErrorAction Stop | Select-Object -ExpandProperty $Name + $Registry = Get-ItemProperty -Path $Path -Name $Name -ErrorAction SilentlyContinue | Select-Object -ExpandProperty $Name If ($Registry -eq $Value) { Write-Output "Compliant" Exit 0 } + ElseIf ($Registry -eq $null) { + Write-Output "Compliant" + Exit 0 + } + Write-Warning "Not Compliant" Exit 1 } Catch { Write-Warning "Not Compliant" Exit 1 -} \ No newline at end of file +}