実行中のExchange / Lyncを遊び心のある手で破壊することを避ける簡単な方法

IISセキュリティ設定をすばやく保存する方法は?



多くの管理者は、IISのいくつかの承認パラメーターを変更し、「今は不要な承認要求でユーザーを苦しめることなく正常に機能する」という状況に直面し、システム全体の部分的に完全に機能ない構成に直面しました。

残念ながら、公式ソースの同じExchange 2013一般的なIIS設定は、可能なすべての構成、特にExchange 2010 / Lync 2013 / Exchange 2013 / Edge TMG 2010の共存シナリオをカバーしていません。次の「チューニング」後後で延期しました。 典型的な推奨事項:「 IISはそれを入手しました-システムを再インストールします 」-それは動作しますが、多くの時間がかかります。

しかし、PowerShellがあります!

この記事では、流れを変えるために設計されたシンプルだが有用なスクリプトの開発の分析を示します。



まず、設定を保存する必要があるサイトを決定する必要があります。 私の場合、典型的な設定との不一致はこのステップですでに現れました。 熟練した手の介入の後に再インストールされたExchange 2013サーバー上のIISは、予想されるものと外観がわずかに異なっていました。



したがって、設定を「現状のまま」保存することは、1つではなく2つのサイトに必要です。

さて、サイトを取得します:

  #見つかった各サイトについて、いくつかの簡単な手順に従います 
 get-website |  ForEach-Object -Process {
 #文字変数へのアプリケーションパスの取得 
 $ xPath = "IIS:\サイト\" + $ _。名前 
 #IIS $ xPath名前空間での移行 
 cd $ xPath 
 #明確にするための結論、我々が得た場所 
 $ xPath
 #現在のサイトでWebアプリケーションのコレクションを取得する 
 $ myWebApp = get-webApplication 
 #コレクションのすべてのメンバーの出力  
 $ myWebApp 
 }




スクリプトの結果:
スクリプトの結果-すべてのサイトのアプリケーションのリスト





手元にあるアプリケーションカタログ、これは何をもたらしますか?

そしてここに何があります:今、私たちはそれらのそれぞれのために認証方法を得ることができます!

これらのパラメータに到達する方法の良い説明はこちらです。

たとえば、Exchangeバックエンドサイトの$ WebAppアプリケーションで基本認証が有効になっているかどうかを表示するコード:



  (Get-WebConfigurationProperty -Filter /system.webServer/security/authentication/basicAuthentication -Name Enabled -PSPath IIS:\ sites \ "Exchange Back End" -location $ WebApp.Path).value 




サイトとアプリケーション自体の名前を入力しないように、このコードをイテレータで「ラップ」する必要があります。 つまり 1つのイテレータがサイトを巡回し、ループ内でサイトのすべてのアプリケーションを巡回します。



簡単にするために、最初に1つのサイトのみの設定を取得し、変数の値を表示するだけで結果を表示します。

スクリプト番号1のバリアント:



 get-webSite
 cd IIS:\ Sites \ "Exchangeバックエンド"
 get-webApplication |  ForEach-Object -process { 
 $ propPath = $ _。パス
 $ propAA =(Get-WebConfigurationProperty -Filter /system.webServer/security/authentication/anonymousAuthentication -Name Enabled -PSPath IIS:\ sites \ "Exchange Back End" -location $ _。Path).value 
 $ propBA =(Get-WebConfigurationProperty -Filter /system.webServer/security/authentication/basicAuthentication -Name Enabled -PSPath IIS:\ sites \ "Exchange Back End" -location $ _。Path).value 
 $ propCA =(Get-WebConfigurationProperty -Filter /system.webServer/security/authentication/clientCertificateMappingAuthentication -Name Enabled -PSPath IIS:\ sites \ "Exchange Back End" -location $ _。Path).value 
 $ propDA =(Get-WebConfigurationProperty -Filter /system.webServer/security/authentication/digestAuthentication -Name Enabled -PSPath IIS:\ sites \ "Exchange Back End" -location $ _。Path).value 
 $ propIA =(Get-WebConfigurationProperty -Filter /system.webServer/security/authentication/iisClientCertificateMappingAuthentication -Name Enabled -PSPath IIS:\ sites \ "Exchange Back End" -location $ _。Path).value 
 $ propWA =(Get-WebConfigurationProperty -Filter /system.webServer/security/authentication/windowsAuthentication -Name Enabled -PSPath IIS:\ sites \ "Exchange Back End" -location $ _。Path).value 
 $ _。パス;  $ propAA;  $ propBA;  $ propCA;  $ propDA;  $ propIA;  $ propWA;
 } 




すでに動作しますが、allいため、すべてのサイトでは動作しません。

PowerShellには素晴らしい出力書式設定コマンドFormat-Tableがあり 、それを実行します。



 #スクリプトテキスト
 get-webSite
 cd IIS:\ Sites \ "Exchangeバックエンド"
 $ myWebApp = get-webApplication
 $ myWebApp |  Format-Table -AutoSize Path、 
 @ {Label = "anonim:"; 式= {(Get-WebConfigurationProperty -Filter /system.webServer/security/authentication/anonymousAuthentication -Name Enabled -PSPath IIS:\ sites \ "Exchange Back End" -location $ _。Path).value}}
 @ {Label = "Basic:"; 式= {(Get-WebConfigurationProperty -Filter /system.webServer/security/authentication/basicAuthentication -Name Enabled -PSPath IIS:\ sites \ "Exchange Back End" -location $ _。Path).value}}
 @ {Label = "ClientCert:"; 式= {(Get-WebConfigurationProperty -Filter /system.webServer/security/authentication/clientCertificateMappingAuthentication -Name Enabled -PSPath IIS:\ sites \ "Exchange Back End" -location $ _。Path).value}}
 @ {Label = "Digest:"; 式= {(Get-WebConfigurationProperty -Filter /system.webServer/security/authentication/digestAuthentication -Name Enabled -PSPath IIS:\ sites \ "Exchange Back End" -location $ _。Path).value}}
 @ {Label = "IIS client Cert:"; 式= {(Get-WebConfigurationProperty -Filter /system.webServer/security/authentication/iisClientCertificateMappingAuthentication -Name Enabled -PSPath IIS:\ sites \ "Exchange Back End" -location $ _。Path).value}}、
 @ {Label = "Windows"; 式= {(Get-WebConfigurationProperty -Filter /system.webServer/security/authentication/windowsAuthentication -Name Enabled -PSPath IIS:\ sites \ "Exchange Back End" -location $ _。Path).value}}
 @ {Label = "SSL Flags"; 式= {(Get-WebConfigurationProperty -Filter /system.webServer/security/access -Name * -PSPath IIS:\ sites \ "Exchange Back End" -location $ _。Path).SSLflags}}

 cd IIS:\ Sites \ "Default Web Site"
 $ myWebApp = get-webApplication
 $ myWebApp |  Format-Table -AutoSize Path、 
 @ {Label = "anonim:";  Expression = {(Get-WebConfigurationProperty -Filter /system.webServer/security/authentication/anonymousAuthentication -Name Enabled -PSPath IIS:\ sites \ "Default Web Site" -location $ _。Path).value}}
 @ {Label = "Basic:"; 式= {(Get-WebConfigurationProperty -Filter /system.webServer/security/authentication/basicAuthentication -Name Enabled -PSPath IIS:\ sites \ "Default Web Site" -location $ _。Path).value}}
 @ {Label = "ClientCert:"; 式= {(Get-WebConfigurationProperty -Filter /system.webServer/security/authentication/clientCertificateMappingAuthentication -Name Enabled -PSPath IIS:\ sites \ "Default Web Site" -location $ _。Path).value}}
 @ {Label = "Digest:"; 式= {(Get-WebConfigurationProperty -Filter /system.webServer/security/authentication/digestAuthentication -Name Enabled -PSPath IIS:\ sites \ "Default Web Site" -location $ _。Path).value}}
 @ {Label = "IIS client Cert:";  Expression = {(Get-WebConfigurationProperty -Filter /system.webServer/security/authentication/iisClientCertificateMappingAuthentication -Name Enabled -PSPath IIS:\ sites \ "Default Web Site" -location $ _。Path).value}}
 @ {Label = "Windows"; 式= {(Get-WebConfigurationProperty -Filter /system.webServer/security/authentication/windowsAuthentication -Name Enabled -PSPath IIS:\ sites \ "Default Web Site" -location $ _。Path).value}}
 @ {Label = "SSL Flags"; 式= {(Get-WebConfigurationProperty -Filter /system.webServer/security/access -Name * -PSPath IIS:\ sites \ "Default Web Site" -location $ _。Path).SSLflags}}
 



ここでは、Format-Tableがイテレータとして機能し、SSLを使用するための「実験」フラグの後に重要な多くの場合失われることも追加しました。



ワイルドな繰り返しコードを記述せず、サイトの名前を手で入力するために、記事の冒頭で行ったように、サイト上にイテレーターを追加します。



スクリプトの最終バージョン:





 get-website |  ForEach-Object -Process { 
 $ xSite = "IIS:\サイト\" + $ _。名前  
 cd $ xSite  
 $ xSite 
 $ myWebApp = get-webApplication
 $ myWebApp |  Format-Table -AutoSize Path、 
 @ {Label = "anonim:"; 式= {(Get-WebConfigurationProperty -Filter /system.webServer/security/authentication/anonymousAuthentication -Name Enabled -PSPath $ xSite -location $ _。Path).value}}、
 @ {Label = "Basic:"; 式= {(Get-WebConfigurationProperty -Filter /system.webServer/security/authentication/basicAuthentication -Name Enabled -PSPath $ xSite -location $ _。Path).value}}、
 @ {Label = "ClientCert:"; 式= {(Get-WebConfigurationProperty -Filter /system.webServer/security/authentication/clientCertificateMappingAuthentication -Name Enabled -PSPath $ xSite -location $ _。Path).value}}
 @ {Label = "Digest:"; 式= {(Get-WebConfigurationProperty -Filter /system.webServer/security/authentication/digestAuthentication -Name Enabled -PSPath $ xSite -location $ _。Path).value}}、
 @ {Label = "IIS client Cert:"; 式= {(Get-WebConfigurationProperty -Filter /system.webServer/security/authentication/iisClientCertificateMappingAuthentication -Name Enabled -PSPath $ xSite -location $ _。Path).value}}
 @ {Label = "Windows"; 式= {(Get-WebConfigurationProperty -Filter /system.webServer/security/authentication/windowsAuthentication -Name Enabled -PSPath $ xSite -location $ _。Path).value}}
 @ {Label = "SSL Flags"; 式= {(Get-WebConfigurationProperty -Filter /system.webServer/security/access -Name * -PSPath $ xSite -location $ _。Path).SSLflags}}
 } 





このオプションでは、Format-Tableコマンド内の$ _は現在のアプリケーションを指し、2行目の$ _はForEach-Objectイテレーターの現在のサイトを指します。



合計すると、出力では、非常に不適切に変更された設定を復元できる美しい画像が得られます。



スクリプトの結果-アプリケーションを認証する方法の表



時間とホスト名を記録して出力をファイルに固定するための多くのオプションがありますが、これは実行されたため、ここでは考慮しませんでした。 改善の余地があります。



組織内のすべてのIISでこのスクリプトを既に実行しているため、何かを変更した場合は、変更内容を思い出すことができます。 「前」と「後」の写真を比較するだけです。 さらなる改善に関するコメントを歓迎します。 バックアップや、「戦闘」サーバー上の何かを変更することは許されていませんが、人生は複雑なものであり、ルールには例外があります。



私のささやかな経験が誰かの時間を節約することを願っています。



All Articles