Drucker per Powershell Managen aktualisiert

cpi
2026-04-20 11:26:25 +02:00
parent 5bcf8bbdbd
commit 5bcbbb10e9
+15
@@ -71,19 +71,23 @@ To rename the printer:
`Rename-Printer -Name "Ricoh IM 2702" -NewName "Ricoh_2702" `Rename-Printer -Name "Ricoh IM 2702" -NewName "Ricoh_2702"
` `
To share a new printer over the network: To share a new printer over the network:
`Set-Printer -Name "Ricoh IM 2702" -Shared $True -ShareName "Ricoh_2702" `Set-Printer -Name "Ricoh IM 2702" -Shared $True -ShareName "Ricoh_2702"
` `
Disable printer sharing: Disable printer sharing:
`Set-Printer -Name "Ricoh IM 2702" -Shared $False `Set-Printer -Name "Ricoh IM 2702" -Shared $False
` `
### List Printers on a Print Server Using PowerShell ### List Printers on a Print Server Using PowerShell
List the printers installed on a computer: List the printers installed on a computer:
`Get-Printer `Get-Printer
` `
The command returns the printer names, types (local or network), driver, print port, whether the printer is shared, and whether it is published in Active Directory. The command returns the printer names, types (local or network), driver, print port, whether the printer is shared, and whether it is published in Active Directory.
Most of the cmdlets in the PrintManagement module can be used to manage printers on remote computers (by using the _-ComputerName_ parameter). Most of the cmdlets in the PrintManagement module can be used to manage printers on remote computers (by using the _-ComputerName_ parameter).
@@ -92,10 +96,12 @@ View a list of printers installed on a remote computer (print server):
`Get-Printer -ComputerName rome-prnt1 | Format-List Name,DriverName `Get-Printer -ComputerName rome-prnt1 | Format-List Name,DriverName
` `
List shared printers on a computer: List shared printers on a computer:
`Get-Printer -ComputerName rome-prnt1 | where Shared -eq $true | fl Name `Get-Printer -ComputerName rome-prnt1 | where Shared -eq $true | fl Name
` `
Get printers that have duplex printing support: Get printers that have duplex printing support:
`Get-Printer | ForEach-Object { Get-PrintConfiguration -PrinterName $_.Name } | Where-Object { $_.DuplexingMode -ne "OneSided" } `Get-Printer | ForEach-Object { Get-PrintConfiguration -PrinterName $_.Name } | Where-Object { $_.DuplexingMode -ne "OneSided" }
@@ -105,23 +111,28 @@ List all the color printers on a computer:
`Get-Printer | ForEach-Object { Get-PrintConfiguration -PrinterName $_.Name } | where {$_.Color -eq $True} `Get-Printer | ForEach-Object { Get-PrintConfiguration -PrinterName $_.Name } | where {$_.Color -eq $True}
` `
Enable color printing mode for a printer: Enable color printing mode for a printer:
`Get-Printer 'HP Color LaserJet 150nw' | Set-PrintConfiguration -Color $true `Get-Printer 'HP Color LaserJet 150nw' | Set-PrintConfiguration -Color $true
` `
Connect a Network Shared Printer with PowerShell Connect a Network Shared Printer with PowerShell
To connect a shared printer from a print server to a computer: To connect a shared printer from a print server to a computer:
`Add-Printer -ConnectionName \\rome-prnt1\HP3027 `Add-Printer -ConnectionName \\rome-prnt1\HP3027
` `
List the network printers connected to a computer: List the network printers connected to a computer:
`Get-Printer | ?{$_.type -eq 'Connection'} `Get-Printer | ?{$_.type -eq 'Connection'}
` `
Remove a specific network printer connection: Remove a specific network printer connection:
`Get-Printer -name \\rome-prnt1\HP3027| Remove-Printer -force `Get-Printer -name \\rome-prnt1\HP3027| Remove-Printer -force
` `
Remove all mapped network printers from your computer: Remove all mapped network printers from your computer:
`Get-Printer | ?{$_.type -eq 'Connection'} | Remove-Printer `Get-Printer | ?{$_.type -eq 'Connection'} | Remove-Printer
@@ -132,6 +143,7 @@ Remove all mapped network printers from your computer:
`Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows" -Name "LegacyDefaultPrinterMode" -Value 1 Force `Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows" -Name "LegacyDefaultPrinterMode" -Value 1 Force
` `
Then use the following commands to set the fixed default printer: Then use the following commands to set the fixed default printer:
``` ```
@@ -146,14 +158,17 @@ To remove a printer, use the command:
`Remove-Printer -Name "HP LaserJet M1530" `Remove-Printer -Name "HP LaserJet M1530"
` `
You can then remove the printer driver from the print server: You can then remove the printer driver from the print server:
`Remove-PrinterDriver -Name "HP Universal Printing PCL 6" `Remove-PrinterDriver -Name "HP Universal Printing PCL 6"
` `
Send a test page for printing: Send a test page for printing:
`Invoke-CimMethod -MethodName printtestpage -InputObject (Get-CimInstance win32_printer | Where-Object Name -eq "HP LaserJet M1530") `Invoke-CimMethod -MethodName printtestpage -InputObject (Get-CimInstance win32_printer | Where-Object Name -eq "HP LaserJet M1530")
` `
Clear the printer queue: Clear the printer queue:
`Get-Printer -Name "HP LaserJet M1530" | Get-PrintJob | Remove-PrintJob `Get-Printer -Name "HP LaserJet M1530" | Get-PrintJob | Remove-PrintJob