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.GetRelate d('Cim_Dat afile')|Se lect Name
$MyVar1=$objItem.GetRelate d('Cim_Dat afile')|Se lect Version
$MyVar2=$objItem.GetRelate d('Cim_Dat afile')|Se lect Caption
$MyVar3=$objItem.GetRelate d('Cim_Dat afile')|Se lect PSComputerName
# $MyVar4=$objItem.GetRelate d('Cim_Dat afile')|Se lect *
Write-Host "Name: " $MyVar0
Write-Host "Version: " $MyVar1
Write-Host "Caption: " $MyVar2
Write-Host "Computer Name: " $MyVar3
# $MyVar4
Write-Host "------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---"
Write-Host
}
# Set name of PC to query
$strComputer = gc c:\temp\MrCleanServerList.
# 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.GetRelate
$MyVar1=$objItem.GetRelate
$MyVar2=$objItem.GetRelate
$MyVar3=$objItem.GetRelate
# $MyVar4=$objItem.GetRelate
Write-Host "Name: " $MyVar0
Write-Host "Version: " $MyVar1
Write-Host "Caption: " $MyVar2
Write-Host "Computer Name: " $MyVar3
# $MyVar4
Write-Host "-------------------------
Write-Host
}
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.