Hello there,
I am a beginner at Powershell and I attempting to write a script to retrieve uninstall software.
Here is what I have so far...
CODE BEGINS
[void][System.Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic')
$PCName = [Microsoft.VisualBasic.Interaction]::InputBox("Enter IP or name of computer to check for Installed Applications (leave blank to check local system).
Remote checking only from NT type OS to NT type OS with same Admin level UID & PW", "PS Installed Apps")
Invoke-Command -ScriptBlock {$RegLoc = Get-ChildItem HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall
$Programs = $RegLoc | foreach {Get-ItemProperty $_.PsPath}
Foreach ($Name in $Programs | Sort-Object DisplayName) `
{Write-Host $Name.Displayname
}} -ComputerName $PCName
Pause
CODE ENDS
Now I like the above code however I am trying to exclude any thing with Security Update for Windows*, however I have been unsuccessful.
I have found another online which does what I need however I cannot get it to run remotely...
CODE BEGINS
$updates=@{}
$unistallPath = "\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
$unistallWow6432Path = "\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\"
@(
if (Test-Path "HKLM:$unistallWow6432Path" ) { Get-ChildItem "HKLM:$unistallWow6432Path"}
if (Test-Path "HKLM:$unistallPath" ) { Get-ChildItem "HKLM:$unistallPath" }
if (Test-Path "HKCU:$unistallWow6432Path") { Get-ChildItem "HKCU:$unistallWow6432Path"}
if (Test-Path "HKCU:$unistallPath" ) { Get-ChildItem "HKCU:$unistallPath" }
) |
ForEach-Object { Get-ItemProperty $_.PSPath } |
Where-Object {
$_.DisplayName -and !$_.SystemComponent -and !$_.ReleaseType -and !$_.ParentKeyName -and ($_.UninstallString -or $_.NoRemove)
} | % {$updates[$_.DisplayName.ToString()]+=@($_)}
$DisplayNames = $updates.Keys | Sort-Object | Out-GridView -Title "Installed Applications"
CODE ENDS
Any Help is greatly appreciated.