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

  • Home
  • SEARCH
  • 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 8439575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T08:01:53+00:00 2026-06-10T08:01:53+00:00

Im currently updating and replacing old outdated nightly scheduled batch files with new self

  • 0

Im currently updating and replacing old outdated nightly scheduled batch files with new self sufficient PowerShell scripts.

The one I am having trouble with is website starts. I am able to use the current test code to get the list of sites and display them but cannot figure out a way to correctly start them if they are stopped.

Set-ExecutionPolicy Unrestricted
start-transcript -path C:\TESTSTART.TXT
#function to get list of websites that are currently stopped
function Get-StoppedSites {
    Import-Module WebAdministration
    $website = Get-ChildItem IIS:\Sites | where {$_.State -eq 'Stopped'}
    write-host "$website is stopped"
    }
#function to start the stopped website
function StartSites {
    param(
    $websitename
    )
    start-website $websitename
    write-host "$website was started"
    }
$Script = Get-StoppedSites
$Script | ForEach-Object{StartSites -websitename $website} 
stop-transcript

When I call this from powershell it acts like it completed with no errors but the website is not started that I had stopped. Windows 2008 R2 server, PS 2.0. I will be running this on 2003 servers once it’s ready to roll out though.

Here is my transcript:

Transcript started, output file is C:\TESTSTART.TXT
 is stopped
Start-Website : Cannot validate argument on parameter 'Name'. The argument is null. Supply a non-null argument and try 
the command again.
At C:\Users\Administrator\Desktop\test.ps1:14 char:18
+     start-website <<<<  $websitename
    + CategoryInfo          : InvalidData: (:) [Start-Website], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.IIs.PowerShell.Provider.StartWebsiteCommand

 was started
**********************
Windows PowerShell Transcript End
End time: 20120823150248

Can you guys help me figure out where/what I’m doing wrong here? Thanks!

  • 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-06-10T08:01:54+00:00Added an answer on June 10, 2026 at 8:01 am

    Try this:

    Set-ExecutionPolicy Unrestricted
    
    Import-Module WebAdministration
    
    $sites = Get-Website | where {$_.State -eq 'Stopped'}
    
    $sites | ForEach-Object {
        $sitename = $_.name
        IF ($sitename -ne $NULL)
        {  
            Write-Host "$sitename is stopped. Starting it..."
            Start-Website $sitename
        }
    }
    

    There are a couple issues with your code. Most importantly, Get-StoppedSites wasn’t actually returning anything, just printing out names. Also, you can use the existing commandlet Get-Website for getting websites.

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

Sidebar

Related Questions

I am currently in the process of updating many test sites on an old
Currently I'm starting a new Activity and calling finish on a current one. Is
I'm currently in the process of updating a (lot of) old xsl+html code to
I am currently updating a MS SQL 2000 server to SQL 2008. One of
We are updating an old .net 1.1 website to 2.0. The site currently supports
I am currently updating an old site where the date used in the database
I'm currently updating a pretty old website (last update was around 2001), and have
I am currently using one button for inserting/updating content within a table. It then
I currently have a table of 3m records that needs updating nightly. The data
I'm currently in progress of updating all sql queries to pdo where I will

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.