问题描述
我正在寻找的快速描述。 我们有运行我们的软件的客户,并且在服务器上的任何地方,多达80台Zebra QLN420打印机均分配了静态IP地址。当我们必须升级其现有服务时,是否应该寻找能够导出所需打印机信息的脚本。我发现了一个Powershell脚本,可以很好地导出到csv文件。问题是Excel没有安装在任何客户服务器上。 所以我想做的是使用每个字段之间的逗号而不是导出到文本文件。无论如何,我都不是Powershell编码器。 我还在Windows上找到了prnport.vbs,它将在端口名,主机地址,端口号中显示我所需的大多数信息,但不会返回PrinterName。
这是导出到Excel的功能。
Param (
string]$Printservers = "myServer"
)
# Create new Excel workbook
cls
$Excel = New-Object -ComObject Excel.Application
#==========$Excel.Visible = $True
$Excel = $Excel.Workbooks.Add("C:\Makeports\Something.xls")
$Sheet = $Excel.Worksheets.Item(1)
$Sheet.Name = "Printer Inventory"
#======================================================
$Sheet.Cells.Item(1,1) = "Print Server"
$Sheet.Cells.Item(1,2) = "Printer Name"
$Sheet.Cells.Item(1,3) = "Location"
$Sheet.Cells.Item(1,4) = "Comment"
$Sheet.Cells.Item(1,5) = "IP Address"
$Sheet.Cells.Item(1,6) = "Driver Name"
$Sheet.Cells.Item(1,7) = "Driver Version"
$Sheet.Cells.Item(1,8) = "Driver"
$Sheet.Cells.Item(1,9) = "Shared"
$Sheet.Cells.Item(1,10) = "Share Name"
#=======================================================
$intRow = 2
$WorkBook = $Sheet.UsedRange
$WorkBook.Interior.ColorIndex = 40
$WorkBook.Font.ColorIndex = 11
$WorkBook.Font.Bold = $True
#=======================================================
# Get printer information
ForEach ($Printserver in $Printservers)
{ $Printers = Get-WmiObject Win32_Printer -ComputerName $Printserver
ForEach ($Printer in $Printers)
{
if ($Printer.Name -notlike "Microsoft XPS*")
{
$Sheet.Cells.Item($intRow,1) = $Printserver
$Sheet.Cells.Item($intRow,2) = $Printer.Name
$Sheet.Cells.Item($intRow,3) = $Printer.Location
$Sheet.Cells.Item($intRow,4) = $Printer.Comment
If ($Printer.PortName -notlike "*\*")
{ $Ports = Get-WmiObject Win32_TcpIpPrinterPort -Filter "name = '$($Printer.Portname)'" -ComputerName $Printserver
ForEach ($Port in $Ports)
{
$Sheet.Cells.Item($intRow,5) = $Port.HostAddress
}
}
####################
$Drivers = Get-WmiObject Win32_PrinterDriver -Filter "__path like '%$($Printer.DriverName)%'" -ComputerName $Printserver
ForEach ($Driver in $Drivers)
{
$Drive = $Driver.DriverPath.Substring(0,1)
$Sheet.Cells.Item($intRow,7) = (Get-ItemProperty ($Driver.DriverPath.Replace("$Drive`:","\\$PrintServer\$Drive`$"))).VersionInfo.ProductVersion
$Sheet.Cells.Item($intRow,8) = Split-Path $Driver.DriverPath -Leaf
}
####################
$Sheet.Cells.Item($intRow,6) = $Printer.DriverName
$Sheet.Cells.Item($intRow,9) = $Printer.Shared
$Sheet.Cells.Item($intRow,10) = $Printer.ShareName
$intRow ++
}
}
$WorkBook.EntireColumn.AutoFit() | Out-Null
}
$intRow ++
$Sheet.Cells.Item($intRow,1) = "Printer inventory completed"
$Sheet.Cells.Item($intRow,1).Font.Bold = $True
$Sheet.Cells.Item($intRow,1).Interior.ColorIndex = 40
$Sheet.Cells.Item($intRow,2).Interior.ColorIndex =
是否有帮助将其导出到以逗号分隔的文件?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)