-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathOhjelmistoinventaari3.ps1
91 lines (71 loc) · 2.68 KB
/
Ohjelmistoinventaari3.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
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# ENHANCED INSTALLED APPLICATION INVENTORY
<# This script will scan the registry to find installed programs by detecting unistaller information or
package information of Microsoft Store application entries. The Script will not detect any portable software packages #>
# Class definitions
class InstalledApp
{
# Properties
[string]$Name
[string]$Version
[string]$InstallDate
[string]$Vendor
[string]$Architecture
}
# Empty array for results
$ResultSet = @()
# Reset application counters
$Counter32bit = 0
$Counter64bit = 0
$CounterStore = 0
# Read registry entries for 32-bit applications
$App32 = Get-ItemProperty "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*"
# Create a new object for every 32-bit app and set properties
foreach($App in $App32)
{
$installedApp = [InstalledApp]::new()
$installedApp.Architecture = "32-bit"
$installedApp.Name = $App.DisplayName
$installedApp.Version = $App.DisplayVersion
$installedApp.Vendor = $App.Publisher
$installedApp.InstallDate = $App.InstallDate
# Add the object to the result array
$ResultSet += $installedApp
# Increment the counter of 32-bit apps
$Counter32bit ++
}
# Read registry entries for 64-bit applications
$App64 = Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*"
# Create a new object for every 64-bit app and set properties
foreach($App in $App64)
{
$installedApp = [InstalledApp]::new()
$installedApp.Architecture = "64-bit"
$installedApp.Name = $App.DisplayName
$installedApp.Version = $App.DisplayVersion
$installedApp.Vendor = $App.Publisher
$installedApp.InstallDate = $App.InstallDate
# Add the object to the result array
$ResultSet += $installedApp
# Increment the counter of 64-bit apps
$Counter64bit ++
}
$StoreApps = Get-ItemProperty "HKCU:\SOFTWARE\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\Repository\Packages\*"
# Create a new object for every Windows Store app and set properties
foreach($App in $StoreApps)
{
$installedApp = [InstalledApp]::new()
$installedApp.Architecture = "Microsoft Store"
$installedApp.Name = $App.DisplayName
$installedApp.Version = $App.DisplayVersion
$installedApp.Vendor = $App.Publisher
$installedApp.InstallDate = $App.InstallDate
# Add the object to the result array
$ResultSet += $installedApp
# Increment the counter of 64-bit apps
$CounterStore ++
}
Write-Warning "Scanned $Counter32bit 32-bit applications"
Write-Warning "Scanned $Counter64bit 64-bit applications"
Write-Warning "Scanned $CounterStore Microsoft Store applications"
Read-Host "Hit Enter to continue"
Write-Output $ResultSet