Link to home
Start Free TrialLog in
Avatar of myhelpermonkey
myhelpermonkey

asked on

Powershell - Get list of Print Drivers

In Powershell, I need to produce a list of the printer drivers installed on a number of different servers.  I found this script online but it does not seem to be working correctly.  If possible, I need it to output the report to a file, such as a csv.  Any help you can provide would be much appreciated.


# Set name of PC to query
 $strComputer = gc c:\temp\MrCleanServerList.txt
 
# Create an array of items from Win32_Printer class in WMI
 $colItems = get-wmiobject -class "Win32_Printer" -namespace "root\CIMV2" -computername $strComputer
 
# Enumerate through the Win32_Printer array and print out properties for each Printer Object
 foreach ($objItem in $colItems)
 {
 Write-Host "Name: " $objItem.Name
 $MyVar0=$objItem.GetRelated('Cim_Datafile')|Select Name
 $MyVar1=$objItem.GetRelated('Cim_Datafile')|Select Version
 $MyVar2=$objItem.GetRelated('Cim_Datafile')|Select Caption
 $MyVar3=$objItem.GetRelated('Cim_Datafile')|Select PSComputerName
 # $MyVar4=$objItem.GetRelated('Cim_Datafile')|Select *
 Write-Host "Name: " $MyVar0
 Write-Host "Version: " $MyVar1
 Write-Host "Caption: " $MyVar2
 Write-Host "Computer Name: " $MyVar3
 # $MyVar4
 Write-Host "----------------------------------------------------------------------------------------"
 Write-Host
 }
SOLUTION
Avatar of Prashant Girennavar
Prashant Girennavar
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial