Repository navigation
Expand file tree
/
Copy pathGetSetRegKeys.ps1
More file actions
58 lines (42 loc) · 1.52 KB
/
Copy pathGetSetRegKeys.ps1
File metadata and controls
58 lines (42 loc) · 1.52 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<#
Get and or Set reg keys as though you were deploying software to a computer,
or for endpoint configuration & tracking purposes
#>
$rootPath = "HKLM:\SOFTWARE\_testing1\"
function Set-InstallationFlag {
param(
[string]$Project,
[string]$Version,
[DateTime]$InstallDate,
[bool]$Success
)
$targetPath = join-path $rootPath $Project
if ((Test-Path $targetPath) -ne $true) {
New-Item -Path $targetPath -Force
};
Set-ItemProperty -Path $targetPath -Name "Version" -Value $Version -Force
Set-ItemProperty -Path $targetPath -Name "InstallDate" -Value $InstallDate -Force
Set-ItemProperty -Path $targetPath -Name "Success" -Value $Success -Force
}
function Get-InstallationFlag {
param(
[string]$Project
)
$targetPath = join-path $rootPath $Project
if (Test-Path $targetPath) {
$version = Get-ItemPropertyValue -Path $targetPath 'Version'
$installDate = Get-ItemPropertyValue -Path $targetPath 'InstallDate'
$success = Get-ItemPropertyValue -Path $targetPath 'Success'
[PSCustomObject]@{
Project = $Project
Version = $version
InstallDate = $installDate
Success = $success
} | Format-Table -AutoSize
}
else {
Write-Host "No information found for $Project."
}
}
Set-InstallationFlag -Project "Adobe" -Version "1.0.22" -InstallDate (Get-Date) -Success $true
Get-InstallationFlag -Project "Adobe"