Windows Vista Forums

Using switches in powershell to go to a specific location

  1. #1


    greatbarrier86 Guest

    Using switches in powershell to go to a specific location

    I seem to recall that you can set up a powershell script to accept a command
    line parameter that would allow you to skip to a certain location in the
    script, but i can't for the life of me recall what it was. It seemed to be
    related to $Status.

      My System SpecsSystem Spec

  2. #2


    Chris Harris Guest

    Re: Using switches in powershell to go to a specific location

    Hi GreatBarrier,
    I'm not 100% certain what you're asking, but this may help:

    param( [string] $switch = "Red")
    switch -regex ($switch){
    "red" {write-host "Red"}
    "blue" {write-host "Blue"}
    Default {write-host "Green"}
    }

    Examples:
    PS C:\Toolbox\Scripts> test-switch Red
    Red
    PS C:\Toolbox\Scripts> test-switch green
    Green
    PS C:\Toolbox\Scripts> test-switch white
    Green
    PS C:\Toolbox\Scripts> test-switch blue
    Blue
    PS C:\Toolbox\Scripts> test-switch
    Red


    "greatbarrier86" <greatbarrier86@xxxxxx> wrote in message
    news:4B540671-81EE-403F-B5BD-EBCDFEB67DFB@xxxxxx

    > I seem to recall that you can set up a powershell script to accept a
    > command
    > line parameter that would allow you to skip to a certain location in the
    > script, but i can't for the life of me recall what it was. It seemed to be
    > related to $Status.

      My System SpecsSystem Spec

  3. #3


    Keith Hill [MVP] Guest

    Re: Using switches in powershell to go to a specific location

    "greatbarrier86" <greatbarrier86@xxxxxx> wrote in message
    news:609A8F99-BDDC-42F6-BFDE-F1B895DA5595@xxxxxx

    > I dont think that's it. What i mean is that i'd like to be able to
    > execute
    > my script, reboot, and start where it left off, requring a switch that
    > would
    > tell it to go to a certain section. Does that make sense?
    There is no "goto" statement in PowerShell however you should be able to do
    something like this:

    param([switch]$AfterReboot)

    if (!$AfterReboot) {
    do stuff
    do more stuff
    put a call to this script with -AfterReboot parameter in the RunOnce reg
    key
    invoke reboot
    }
    else {
    do post reboot stuff here.
    }

    --
    Keith


      My System SpecsSystem Spec

Using switches in powershell to go to a specific location

Similar Threads
Thread Forum
How can i start Explorer in specific location ?
Hi, When i start my explorer (in Vista Ultimate), it starts in C:\Users\user\Appdata\Roaming\Microsoft\windows\programs ... Is there any way i...
Vista performance & maintenance
cannot publish the movie to the specific location
I tried to publish my video to be the WMV format. But then it says that It cannot publish the movie to the specific location. And that I have to...
Vista music pictures video
VBScript to list PST files and their location on a specific drive ona PC to a CSV file
Hi guys I need to list all the PST files on a server and for convenience put them in a CSV or TXT file. I need their locations as well. Now, I...
VB Script
Using EXE Switches in Powershell
Hi, How do you invoke an exe with a certain switch in powershell? It doesnt seem to like it the way i am doing it. My current way is simply...
PowerShell
Can one put offline files at a specific location?
I would like to make certain folders available offline, but at the same time I would like to put them in specific local locations, i.e. not under...
Vista file management
Saving to a specific location
I know i'm being real lazy here but when I save a file to a specific folder I look through the folders, for example, my computer: my pictures:...
Vista file management
Info: Can you Position Text at specific location on the screen even as it changes
Goal: ----- I am creating a reboot script that will reboot a list of servers. I would like the status of reboot as we go (i.e. Down, Reboot Sent,...
PowerShell