Try
{
Write-Verbose "Get the specified printer info."
$Printer = $Printers | Where{$_.Name -eq "$PrinterName"}
If($Printer)
{
Write-Verbose "Setting the default printer."
$Printer.SetDefaultPrinter() | Out-Null
Write-Host "Successfully set the default printer."
}
Else
{
Write-Warning "Cannot find the specified printer."
}
}
Catch
{
$ErrorMsg = $_.Exception.Message
Write-Host $ErrorMsg -BackgroundColor Red
}
https://gallery.technet.microsoft.com/scriptcenter/How-to-set-default-printer-cf89670b
{
Write-Verbose "Get the specified printer info."
$Printer = $Printers | Where{$_.Name -eq "$PrinterName"}
If($Printer)
{
Write-Verbose "Setting the default printer."
$Printer.SetDefaultPrinter() | Out-Null
Write-Host "Successfully set the default printer."
}
Else
{
Write-Warning "Cannot find the specified printer."
}
}
Catch
{
$ErrorMsg = $_.Exception.Message
Write-Host $ErrorMsg -BackgroundColor Red
}
https://gallery.technet.microsoft.com/scriptcenter/How-to-set-default-printer-cf89670b
Комментариев нет:
Отправить комментарий