forked from AutomoxCommunity/Templates_And_Examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Example_EXE_EVALUATION_ScriptBlock.ps1
30 lines (24 loc) · 1.07 KB
/
Example_EXE_EVALUATION_ScriptBlock.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#REQUIRES -Version 2.0
#Handle Exit Codes:
trap { $host.ui.WriteErrorLine($_.Exception); exit 90 }
#### Check Registry with ScriptBlock
$scriptBlock = {
# Define registry key path, registry value, and the desired value data
#############################################
$regPath = "HKLM:SOFTWARE\Dell\Dell Data Protection"
$regProperty = "EEVersion"
$desiredValue = '10.5.0.1'
#############################################
# Retrieve current value for comparison
$currentValue = (Get-ItemProperty -Path $regPath -Name $regProperty).$regProperty
return $currentValue
}
# Execute the ScriptBlock in a 64-bit shell,
# No need to assign to a variable if you don't
# have a return value. In most cases, you will.
$currentValue = & "$env:SystemRoot\sysnative\WindowsPowerShell\v1.0\powershell.exe" -ExecutionPolicy Bypass -WindowStyle Hidden -NoProfile -NonInteractive -Command $scriptBlock
# Compare current with desired and exit accordingly.
# 0 for Compliant, 1 for Non-Compliant
if ($currentValue -eq $desiredValue) {
Exit 0
} else { Exit 1 }