2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

不要なプリンターを削除

Last updated at Posted at 2015-05-27

Canon LBP3910のプリンターをクライアントから削除したいです。
会社でCanon LBP3910を退役させて、Canon LBP8710eを導入しました。
しかし、営業中に社員のPCを拝借して設定するのはできるだけ避けたい。

コマンド一発で削除できればいいんだけどなぁ。

Win32_Printerが適えてくれるよ

Powershell v3.0からは Get-WmiObject というCmdletで、
Win32_Printerを呼び出し、
プリンターの一覧を取得することができる。

その中から該当するプリンターを選び出し削除することもできる。

やり方は下記のスクリプトの通り

printerdel.ps1
# プリンター一覧を取得
$printerlist=Get-WmiObject Win32_Printer
# LBP3910 という名前を含むプリンターを選んで $delprinterlist に格納
$delprinterlist=$printerlist | Where-Object Name -match "LBP3910"
# Delete()を実行して該当するプリンターをすべて削除
$delprinterlist.Delete()

Win32_PrinterDriver(プリンタードライバー)でも
Win32_TcpIpPrinterPort(プリンターポート)でも同じような作業で、
削除や編集ができる。

プリンターポートの変更
# プリンターポートをすべて取得
$ports = Get-WmiObject Win32_TcpIpPrinterPort
# 変更したいプリンターポートを取得
$port = $ports.get(0)
# Name部分を変更
$port.Name=60
# 変更を実行
$port.add()
2
2
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?