Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Software List

$
0
0

Hi , I have following script to search domain root for computer and list the installed applications, while output is to console having difficulty getting it to a CSV file. Can anyone please help ?

$datetime = Get-Date -Format "ddMMMyyyy"
$strCategory = "computer";

# Connect to root of domain
$objDomain = New-Object System.DirectoryServices.DirectoryEntry;
# AD Searcher object
$objSearcher = New-Object System.DirectoryServices.DirectorySearcher;
# Set Search to root of domain
$objSearcher.SearchRoot = $objDomain;
# Search filter
$objSearcher.Filter = ("(objectCategory=$strCategory)");

$colProplist = "name";
foreach ($i in $colPropList)
{
$objSearcher.PropertiesToLoad.Add($i);
}

$colResults = $objSearcher.FindAll();


# Add column headers

Add-Content "$Env:USERPROFILE\Software_List $datetime.csv" "Computer,DisplayName,DisplayVersion,Publisher";

foreach ($objResult in $colResults)
{
$objComputer = $objResult.Properties;
$computer = $objComputer.name;

$ipAddress = $pingStatus.ProtocolAddress;
# Ping the computer
$pingStatus = Get-WmiObject -Class Win32_PingStatus -Filter "Address = '$computer'";

if($pingStatus.StatusCode -eq 0)
{
Write-Host -ForegroundColor Green "Ping Reply received from $computer.";

write-host "Connecting to $computer..."

$colItems = Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\* `
-Computername $computer

write-host "#############################"
write-host "Computer: " $computer
write-host "#############################"

foreach ($objItem in $colItems)
{
Write-Host "Computer: "$objComputer.name
$caption = $objItem.Computername;
write-host "Displayname: " $objItem.displayname
$caption = $objItem.Displayname;
write-host "Version: " $objItem.DisplayVersion
$caption = $objItem.Description;
write-host "Publisher: " $objItem.Publisher
$caption = $objItem.Publisher;
}
}

Add-Content "$Env:USERPROFILE\software_list $datetime.csv" "$Computername,$Displayname,$Displayversion"


}

else

{
Write-Host -ForegroundColor Red "No Ping Reply received from $computer"
}


Yasar


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>