Score:0

Script to Create IIS Site Failing

kr flag

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

in flag
Does the directory C:\inetpub\IdpSAMLBridge\abc5 exist? Can you show what's in there?
kr flag
The directory does exist. Its got a deployed ASP.NET application. There are several such sites on this server. I created those ones in IIS manually.
cn flag
Try using New-WebSite, I never had any problems with that one. Hardly ever use the *-IIS* ones.
kr flag
@PeterHahndorf But that's my whole goal. To do it using the new Module. I know the WebAdministration module stuff works. But I want to learn how to do it using `IISAdministration`. And I can't, for the life of me, understand why it is not working.
in flag
Oh hey, you've completely swapped around which error message you're getting.
kr flag
@Grilse yeah. That's on me. I edited the question with more details. This was the error I was getting on the server. I thought it was the same on my laptop, until I looked a lot closer.
Score:3
tz flag

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

in flag
Yup, that's the badger: "We’ve also updated the New-IISSite cmdlet to allow you specify a HTTPS binding at site creation."
kr flag
@Ryan Bolger Awesome! whilst I read the docs, I did not know about that blog post. Thanks for sharing your knowlege. My Google-fu did not even pick it up.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.