PowerShell で IIS 7.5 のハンドラーマッピングの作成・変更・削除

by kusakari 12. 2月 2010 21:12

PowerShell から IIS 7.5 のハンドラーマッピングの操作(作成・変更・削除)をしてみたいと思います。

環境は前回からの続きで、下記の環境です。

  • IIS 7.5
  • PowerShell 2.0

 

■参照
まずは、現在のハンドラマッピングの状況を確認してみたいと思います。
現在の、Default Web Site に対するマッピング状況を出力するには、下記のコマンドで一覧を出力できます。

Get-WebHandler -PSPath "iis:/sites/default web site"

 


もしくは、下記のような感じでも参照出来ます。

Get-WebConfiguration /system.webserver/handlers/* -PSPath "iis:/sites/default web site"

 

 

■作成
次に、下図のような感じのハンドラーマッピングを、PowerShellから Default Web Site に対して作成するには...。
2010212_204822_720

 

次のような感じのコマンドを入力します。

New-WebHandler -Name "CGI" -Path *.cgi -Verb * -Modules IsapiModule -ScriptProcessor "c:\perl\bin\perlis.dll" -PSPath "iis:/sites/default web site"

 

 

 

■変更
次に、今作成したハンドラーマッピングの設定を編集してみたいと思います。
ハンドラーマッピングの名前を「CGI-2」に変更したい場合は、例えば下記のような感じで変更できます。

Set-WebConfiguration "/system.webserver/handlers/add[@name='CGI']/@name" -Value "CGI-2" -PSPath "IIS:/sites/Default Web Site"

 

 

また、実行可能ファイルのパスを「C:\Perl\bin\perlis.dll」から「C:\Perl\bin\perl.exe "%s" %s」に変更するには、下記のような感じにコマンドを入力します。

Set-WebConfiguration "/system.webserver/handlers/add[@name='CGI-2']/@scriptProcessor" -Value "C:\Perl\bin\perl.exe ""%s"" %s" -PSPath "IIS:/sites/Default Web Site"

 

変更した結果は下図のようになります。
 2010212_21328_721

 

 

 

■削除
上で設定した、Default Web Site にマップしている「CGI-2」のハンドラーマッピングの削除を行うには、下記のような感じで削除できます。

Remove-WebHandler -Name "CGI-2" -PSPath "iis:/sites/default web site"

コメントを書く


(アイコンを表示しますか Gravatar )

  Country flag

biuquote
  • コメント
  • プレビュー
Loading



Calendar

<<  7月 2010  >>
月曜火曜水曜木曜金曜土曜日曜
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678

View posts in large calendar

RecentComments

Comment RSS