-
Notifications
You must be signed in to change notification settings - Fork 0
/
Get-Item01.ps1
32 lines (30 loc) · 899 Bytes
/
Get-Item01.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
31
32
#Checking if a Registry Key Exists
$Key = "HKEY_LOCAL_MACHINE\SOFTWARE\FSLogix\Profiles"
If(Test-Path -Path "Registry::$Key") {
Write-host -f Green "Key Exists!"
}
Else {
Write-host -f Yellow "Key doesn't Exists!"
}
#Checking if a Registry Value Exists
$RegPath = "HKLM:\SOFTWARE\FSLogix\Profiles"
$RegValue = "Version"
$RegistryKey = Get-Item -Path $RegPath -ErrorAction SilentlyContinue
if ($RegistryKey.GetValueNames() -contains $RegValue) {
# Value exists
Write-host -f Green "Value Exists!"
}
else {
# Value does not exist
Write-host -f Yellow "Value Doesn't Exists!"
}
#Checking if a Registry Value Exists
$Value = Get-ItemProperty -Path 'HKLM:\SOFTWARE\MyApp' -Name 'Version' -ErrorAction SilentlyContinue
If ($value) {
# Value exists
Write-host -f Green $Value.Version
}
else {
# Value does not exist
Write-host -f Yellow "Value doesn't Exists!"
}