forked from MicksITBlogs/PowerShell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GetSoftwareNameGUID.ps1
72 lines (60 loc) · 2.58 KB
/
GetSoftwareNameGUID.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
#*******************************************************************************
# Author: Mick Pletcher
# Date: 30 November 2013
#
# Program: Get Software Names and GUID
#*******************************************************************************
Clear-Host
Function RenameWindow ($Title) {
#Declare Local Memory
Set-Variable -Name a -Scope Local -Force
$a = (Get-Host).UI.RawUI
$a.WindowTitle = $Title
#Cleanup Local Memory
Remove-Variable -Name a -Scope Local -Force
}
Function GetProductName($Description) {
#Declare Local Memory
Set-Variable -Name AppLocal -Scope Local -Force
Set-Variable -Name AppName -Scope Local -Force
Set-Variable -Name Desc -Scope Local -Force
Set-Variable -Name IDLocal -Scope Local -Force
Set-Variable -Name IDNumber -Scope Local -Force
Set-Variable -Name Uninstaller -Scope Local -Force
#Change '%application%' to whatever app you are calling
$Description = [char]34+"description like"+[char]32+[char]39+[char]37+$Description+[char]37+[char]39+[char]34
$Desc = wmic product where $Description get Description
$Uninstaller = wmic product where $Description get IdentifyingNumber
$Desc | ForEach-Object {
$_ = $_.Trim()
if(($_ -ne "Description")-and($_ -ne "")){
$AppName += $_
}
}
$Uninstaller | ForEach-Object {
$_ = $_.Trim()
if(($_ -ne "IdentifyingNumber")-and($_ -ne "")){
$IDNumber += $_
}
}
$AppLocal = New-Object System.Object
$AppLocal | Add-Member -type NoteProperty -name Application -value $AppName
If ($AppName -ne $null) {
$AppLocal | Add-Member -type NoteProperty -name GUID -value $IDNumber
} else {
$AppLocal | Add-Member -type NoteProperty -name Status -value "Not Installed"
}
$AppLocal
#Cleanup Local Memory
Remove-Variable -Name AppLocal -Scope Local -Force
Remove-Variable -Name AppName -Scope Local -Force
Remove-Variable -Name Desc -Scope Local -Force
Remove-Variable -Name IDLocal -Scope Local -Force
Remove-Variable -Name IDNumber -Scope Local -Force
Remove-Variable -Name Uninstaller -Scope Local -Force
}
RenameWindow "Product Name and GUID"
GetProductName "Office Professional Plus"
GetProductName "Microsoft Lync 2013"
GetProductName "Adobe Reader"
GetProductName "Microsoft Visio Professional"