
我正在嘗試使用新IISAdministration
模組建立 IIS 網站(我知道我可以使用舊WebAdministration
模組,但這是現在推薦的方法)。
當我運行以下腳本時,出現以下錯誤:
Import-Module IISAdministration
New-IISSite -Name "IdpSAMLBridge" -BindingInformation "*:7777:demo.something.com" -PhysicalPath "C:\inetpub\IdpSAMLBridge\abc5" -Protocol https -CertificateThumbPrint "284c9018f6f6258a05c48ab9e34f6fe2133cff1b" -CertStoreLocation "Cert:\LocalMachine\My"
和錯誤:
New-IISSite : A parameter cannot be found that matches parameter name 'Protocol'.
... indingInformation '*:12031:ictctst.incontrol.local' -Protocol https - ...
~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [New-IISSite], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.IIS.Powershell.Commands.NewIISSiteCommand
如果這個 doco 仍然正確並且是最新的,我的程式碼似乎是正確的。
如果我交換參數,我會得到類似的錯誤,但參數不同:
New-IISSite : A parameter cannot be found that matches parameter name 'CertificateThumbPrint'.
At C:\Users\David\Documents\scripts\create-idp.ps1:3 char:132
+ ... tion '*:12031:ictctst.incontrol.local' -CertificateThumbPrint 'f62d70 ...
+ ~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [New-IISSite], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.IIS.Powershell.Commands.NewIISSiteCommand
但是,如果我刪除一些參數,則該命令將起作用:
Import-Module IISAdministration
New-IISSite -Name "IdpSAMLBridge" -PhysicalPath 'C:\inetpub\IdpSAMLBridge\abc5' -BindingInformation '*:12033:demo.something.com'
有什麼想法可能是什麼問題嗎?
謝謝
答案1
您可能嘗試使用此模組的作業系統本機版本 1.0.0.0,但功能不如目前版本 1.1.0.0 豐富,目前版本 1.1.0.0 可透過PowerShell 畫廊並且也與 Windows Server 2022 捆綁在一起。
您可以使用以下命令驗證您的版本:
Get-Module -List IISAdministration
您也可以像這樣驗證可用參數:
Get-Help New-IISSite
這是 IIS 團隊在 2017 年發布的部落格文章,宣布推出該模組的新版本。 https://blogs.iis.net/iisteam/introducing-iisadministration-in-the-powershell-gallery