Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6911589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:58:36+00:00 2026-05-27T08:58:36+00:00

I created a function to create a site in IIS, but Im running into

  • 0

I created a function to create a site in IIS, but I”m running into a bizzare error.

Here’s the url I’ve been using as a reference:

http://learn.iis.net/page.aspx/433/powershell-snap-in-creating-web-sites-web-applications-virtual-directories-and-application-pools/

New-Item : Index was outside the bounds of the array.

At line:1 char:9
+ New-Item <<<< ‘IIS:\Sites\SiteName’ -physicalPath “$sitePath” -bindings @{protocol=”$protocol”;bindingInformation=”$fullBindings”}
+ CategoryInfo : NotSpecified: (:) [New-Item], IndexOutOfRangeException
+ FullyQualifiedErrorId : System.IndexOutOfRangeException,Microsoft.PowerShell.Commands.NewItemCommand

Here’s the code block that calls the function:

    function Create-FullSite($site, $framework, $userName, $password, $protocol, $port, $enabledProtocols)
            {
                #Write-Host "Prompting for path to "
                $sitePath = Select-Folder

                #Write-Host $sitePath

                #Write-Host "Setting up app pool for "
                $csServicePool = New-Item -Path iis:\AppPools\$site

                #Write-Host "Configuring app pool"
                Set-ItemProperty -Path IIS:\AppPools\$site -name managedRuntimeVersion -value $framework
                $csServicePool.processModel.username = $userName
                $csServicePool.processModel.password = $password
                $csServicePool.processModel.identityType = 3
                $csServicePool  | set-item 

                #Write-Host "Creating IIS Site "

                $fullBindings = ':'+$port.ToString()+':'
                Write-Host $fullBindings

                Write-Host $site    
                Write-Host $sitePath
                Write-Host $protocol

                New-Item IIS:\Sites\$site -physicalPath "$sitePath" -bindings @{protocol="$protocol";bindingInformation="$fullBindings"}

                #Write-Host "Assigning App pool to "



                Set-ItemProperty -Path IIS:\Sites\$site -name ApplicationPool -value $site

                #Write-Host "setting applicationDefaults.enabledProtocols: "
                Set-ItemProperty -Path IIS:\Sites\$site -name applicationDefaults.enabledProtocols -value "$enabledProtocols"

                return $sitePath
            }   

    $ServicesSiteName = 'MyNewSite'
            $ServicesPort = '80'
            $ServiceBindings = 'http'

            $csWebServiceUserName = 'domain\someUser'
            $csWebServicePassword = 'AReallyComplexPassword'

            $v2Framework = 'v2.0'
            $v4Framework = 'v4.0'

           Create-FullSite $ServicesSiteName $v2Framework $csWebServiceUserName $csWebServicePassword $ServiceBindings $ServicesPort $ServiceBindings
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T08:58:37+00:00Added an answer on May 27, 2026 at 8:58 am

    It turns out if you delete all the websites in IIS, the “Index Out of Range” exception is always thrown. I have a feeling it’s trying to generate a site id and cannot find the next one in the list. This article helped me solve the issue. http://forums.iis.net/t/1159761.aspx

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I created the following function to simplify a piece of particularly complex code. CREATE
I have a question regarding an update function I created... CREATE OR REPLACE FUNCTION
we are trying to create a calendar function in python. we have created a
iam trying to implement an Searchmachine into my site. Iam using Zend_Search_Lucene for this.
I created a site a while ago using zend and smarty. The site is
I'm trying to create a fadeIn/Out effect on a site I created (edit: site
I am learning to create a website and using a pre-created HTML template so
I am trying to create a site-specific browser application. I've created a new Cocoa
The MSDN site says: From your view class's function that handles the WM_CREATE message
I have a win form that creates a site in IIS7. One function needs

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.