-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGet-InstalledSoftware.ps1
More file actions
62 lines (56 loc) · 2.11 KB
/
Copy pathGet-InstalledSoftware.ps1
File metadata and controls
62 lines (56 loc) · 2.11 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
59
60
61
# This script searches for an installed software on all domain computers
$softwarename = "*7-Zip*"
$computers = Get-ADComputer -Filter * | Select-Object -ExpandProperty Name
foreach ($computer in $computers) {
try {
Invoke-Command -ComputerName $computer -ScriptBlock {
Get-ItemProperty -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*" |
Where-Object { $_.DisplayName -like $softwarename } |
Select-Object @{
Name = "PSComputerName"; Expression = { $env:COMPUTERNAME }
}, DisplayName, @{Name = "Version"; Expression = { $_.Version } }
}
}
catch {
$errorMessage = $_.Exception.Message
Write-Output ("Fehler bei {0}: {1}" -f $computer, $errorMessage)
}
}
function Get-InstalledSoftware {
<#
.SYNOPSIS
Liest installierte Software (Registry-basiert, ohne Win32_Product)
#>
[CmdletBinding()]
param(
[string]$ComputerName = $env:COMPUTERNAME
)
$hives = @(
@{ Path = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*'; Architecture = '64-bit' },
@{ Path = 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*'; Architecture = '32-bit' }
)
$scriptBlock = {
param($hives)
$apps = foreach ($entry in $hives) {
Get-ItemProperty -Path $entry.Path -ErrorAction SilentlyContinue |
Where-Object { $_.DisplayName -and $_.UninstallString } |
ForEach-Object {
[PSCustomObject]@{
Name = $_.DisplayName
Version = $_.DisplayVersion
Publisher = $_.Publisher
InstallDate = $_.InstallDate
UninstallString = $_.UninstallString
Architektur = $entry.Architecture
}
}
}
$apps | Sort-Object Name
}
if ($ComputerName -eq $env:COMPUTERNAME) {
& $scriptBlock $hives
}
else {
Invoke-Command -ComputerName $ComputerName -ScriptBlock $scriptBlock -ArgumentList $hives
}
}