Hi, today I want to show you how to share a printer using PowerShell. The cmdlet I will use is Set-Printer. This cmdlet allows to establish or update the configuration of the specified printer.
To share a printer with PowerShell, use the Set-Printer cmdlet with the following syntax:
1 2 3 4 5 | Set-Printer -Name "printer name" -Shared $True|$False -ShareName "share name" |
The workaround in a local computer
With the Get-Printer cmdlet, we obtain the list of installed printers and their basic properties. The “Shared” column shows us if the printer is already shared.
Now that we have the printer’s data that we want to share, we use the Set-Printer cmdlet. Run PowerShell console as administrator, and then type:
Then you can verify the job with the Get-Printer cmdlet.
The workaround in a remote computer
To share the printer from a remote server, use the -ComputerName parameter to specify the name or IP of the remote computer. The syntax is the following:
1 2 3 4 5 6 | Set-Printer -ComputerName "Remote Computer" ` -Name "printer name" ` -Shared $True|$False ` -ShareName "share name" |
Again, we verify that the printer is shared with the Get-Printer cmdlet with the -ComputerName parameter.
If you want to know more about the Set-Printer cmdlet, check out this link: https://docs.microsoft.com/en-us/powershell/module/printmanagement/set-printer?view=win10-ps