Below is part of script that I wrote to audit the software installed on a PC, and return a list of programs that are not part of our standard build.
This seems to be working perfect for about 99% of our systems. I started investigating the few that were not returning results. I found that if I ran the script from my local c:, results were returned as expected. However, when the script is ran from a network share, no results are returned, and no errors occur.
Any ideas?
$computer = read-host "Computer Name"
$arryStandardSoftware = get-content -path "StandardSoftware.txt"| Foreach-Object{$_.trim()}
$AuditResult = (Get-WMIObject -namespace "root\cimv2\sms" -class sms_installedsoftware -computername "$computer"|
Select-Object productname|Where-Object{$arryStandardSoftware -notcontains "$($_.productname)"})
$AuditResult