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 3219502
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:39:13+00:00 2026-05-17T15:39:13+00:00

I have a powershell script I want to be able to define different starting

  • 0

I have a powershell script I want to be able to define different starting points for. Once the starting point is hit the script would pick up from that point and continue through the remaining code in the script. I don’t believe that a case statement will work since I don’t think that will just let the script flow through from whatever starting point is defined.

I would expect to see something like this when the script was started.

Please choose your starting point:

  1. Beginning
  2. Start at step 2
  3. Start at step 3 etc…..

When the selection is made the script jumps to that point then will run through the remainder of the script.

Answer: The code is going to end up looking something like this:

#steps
$stepChoice = read-host 'Where would you like to start.'

switch($stepChoice)
{
    1{Step1}
    2{Step2}
    3{Step3}

}

function Step1 { 
    'Step 1' 
    Step2 
} 
function Step2 { 
    'Step 2' 
    Step3 
} 
function Step3 { 
    'Step 3' 
    'Done!' 
}

Thanks for your help

  • 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-17T15:39:14+00:00Added an answer on May 17, 2026 at 3:39 pm

    AFAIK, there is nothing like this in PowerShell. If you need something simple this might work for you:

    *) Create a script with steps defined as functions. Each function in the end calls the next step-function:

    # Steps.ps1
    function Step1 {
        'Step 1'
        Step2
    }
    function Step2 {
        'Step 2'
        Step3
    }
    function Step3 {
        'Step 3'
        'Done!'
    }
    

    *) If you want to start with step 1: dot-source the Steps.ps1 and call Step1:

    . .\Steps.ps1
    Step1
    

    *) If you want to start with step 2: dot-source the Steps.ps1 and call Step2:

    . .\Steps.ps1
    Step2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Powershell script that copies files from one location to another. Once
I have the following string expression in a PowerShell script: select count(*) cnt from
Does anyone have a Powershell script to change the credentials used by a Windows
I have a simple PowerShell script that uses WMI to create a web site
I have a few lines of PowerShell code that I would like to use
I have a powershell script to iterate through a list of LinkedServer objects in
I have a Powershell script that is going to be run through an automation
I have a PowerShell script that outputs to stdout and stderr. I'd like to
We have a script to delete the svn:mergeinfo property from all folders inside a
I have one big batch script which sets bunch of environment variables. I want

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.