Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Using switches in powershell to go to a specific location

Reply
 
Old 04-30-2008   #1 (permalink)
greatbarrier86


 
 

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
Old 05-01-2008   #2 (permalink)
Chris Harris


 
 

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
Quote:

> 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
Old 05-02-2008   #3 (permalink)
Keith Hill [MVP]


 
 

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

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

> 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
Reply

Thread Tools


Similar Threads
Thread Forum
How can i start Explorer in specific location ? Vista performance & maintenance
cannot publish the movie to the specific location Vista music pictures video
Using EXE Switches in Powershell PowerShell
Can one put offline files at a specific location? Vista file management
Saving to a specific location Vista file management


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46