Script to Create IIS Site Failing
I am trying to use the new IISAdministration
module to create an IIS site (I know I can use the old WebAdministration
module, but this is now the recommended approach).
When I run the following script, I get the error that follows it:
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"
And the error:
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
My code seems to be correct, if this doco is still correct and current.
If I swap around the parameters, I get a similar error, but a different parameter:
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
However, if I remove some of the parameters, the command works:
Import-Module IISAdministration
New-IISSite -Name "IdpSAMLBridge" -PhysicalPath 'C:\inetpub\IdpSAMLBridge\abc5' -BindingInformation '*:12033:demo.something.com'
Any ideas what the issue could be?
Thanks
Solution 1:
You're likely attempting to use the OS-native version of the module which is 1.0.0.0 and not as feature rich as the current version 1.1.0.0 which is available via PowerShell Gallery and is also bundled with Windows Server 2022.
You can verify your version with the following command:
Get-Module -List IISAdministration
You can also verify the available parameters like this:
Get-Help New-IISSite
Here's a blog post from the IIS team announcing the new version of the module back in 2017. https://blogs.iis.net/iisteam/introducing-iisadministration-in-the-powershell-gallery