0
私は小さなps1スクリプトを書いてキューをクリアし、エンドユーザーが選択したプリンタでスプールを再開します。私が今までに持っているのは、特定のマシンのデフォルトプリンタで意図されていたものですが、どのプリンタが問題になっているのかを正確に選択できるようにする必要があります。現在の機能スクリプトは次のとおりです。テストページを指定されたプリンタに印刷するにはどうすればよいですか?
net stop spooler
Remove-Item C:\Windows\System32\spool\PRINTERS\* -Force
net start spooler
$printer = Get-WmiObject -Query " SELECT * FROM Win32_Printer WHERE Default=$true"
$PrintTestPage = $printer.PrintTestPage()
$wshell = New-Object -ComObject Wscript.Shell
$wshell.Popup("I found a problem that I was able to fix. Please try to print again.",0,"Printer Helper",0x1)
私は、次のようにしてユーザーの入力を許可するようにスクリプトを変更しようとしました。
net stop spooler
Remove-Item C:\Windows\System32\spool\PRINTERS\* -Force
net start spooler
get-printer
$printer = Read-Host -Prompt 'Please Type In The Name Of The Printer That You Are Having Problems With'
$PrintTestPage = $printer.PrintTestPage()
$wshell = New-Object -ComObject Wscript.Shell
$wshell.Popup("I found a problem that I was able to fix. Please try to print again.",0,"Printer Helper",0x1)
ただし、次のエラーが発生します。
[System.String]に 'PrintTestPage'という名前のメソッドが含まれていないため、メソッドの呼び出しに失敗しました。
どうすれば対処できますか?
感謝を!これは美しく動作します。 –