LoginSignup
3
7

More than 5 years have passed since last update.

PowerShellで、プリンタドライバをインストールする

Last updated at Posted at 2017-02-28

参考URL: LAN内の全PCに自動でプリンタードライバーをインストールする方法
http://www.se-support.com/clientpc/printer-install.html

上記サイトではバッチファイルが紹介されています。
これをPowerShell で置き換えてみます。
変更点は、「OSは問わないが 64bit or 32bit で区別されているドライバ」に対応させました。
プリンタドライバは、共有フォルダ \\public の配下にあるそれぞれのフォルダ内で解凍しておきます。

64bit版の場合: "\\public\64bit\fxap4c5575plw150110wxp6fja\"
32bit版の場合: "\\public\32bit\fxap4c5575plw150110w2k3fja\"

プリンタの作成には、以下のフォルダ内にある VBScript(.vbs) を使用します。

C:\Windows\System32\Printing_Admin_Scripts\ja-JP\cscript prndrvr.vbs

記述するとこんな感じです。
PCの台数が多いときは、このスクリプトを
ログオンスクリプトで 1回だけ実行させれば一撃です。

install_xerox_c4475.ps1
##--- config ---
# プリンタのIPアドレス
$ipaddress = "192.168.1.100"

# 解凍したプリンタドライバパッケージ内のinfファイルに記述されている、プリンタの名称
$inf_printername = "FX DocuCentre-IV C4475"

# PCの「デバイスとプリンター」に表示されるプリンタの名称
$printername = "DocuCentre-ⅣC4475"

##--- main ---
Set-Location C:\Windows\System32\Printing_Admin_Scripts\ja-JP\

# 通信ポートの作成
$port_name = "IP_" + $ipaddress
cscript prnport.vbs -a -r $port_name -h $ipaddress -o raw -n 9100

#--- OS の bit を判定する ---
$os = Get-WmiObject -Class Win32_OperatingSystem
# Write-Host $os.OSarchitecture

if ( $os.OSarchitecture -eq "64 ビット" )
    {
    # 64bit版ドライバのインストール
    cscript prndrvr.vbs -a -m $inf_printername -v 3 `
    -i "\\public\64bit\`
    fxap4c5575plw150110wxp6fja\cswnd\ART_EX\x64\FXLKNJL.inf"
    }
else
    {
    # 32bit版ドライバのインストール
    cscript prndrvr.vbs -a -m $inf_printername -v 3 `
    -i "\\public\32bit\ `
    fxap4c5575plw150110w2k3fja\cswnd\ART_EX\Win2000_XP\FXLKNJL.inf"
    }

# プリンタの作成
cscript prnmngr.vbs -a -p $printername -m $inf_printername -r $port_name
##--- end ---
3
7
4

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
3
7