Chris Stauffer at myITForum.com

You want me to do What?

Syndication

News

Links to blogs i like

Links

My First PowerShell Script

 Here is my first powershell script :-P

 

$strString = "Hello World"
$i=100;do {$i--; "$i"} until ($i -eq 0)
""
write-host $strString -ForegroundColor red

 

Published Friday, July 11, 2008 8:09 AM by cstauffer
Filed under:

Comments

# re: My First PowerShell Script@ Friday, July 11, 2008 10:51 AM

A recommendation to make your first a little more Powershell-ish.

1..100 | foreach-object { Write-host -Fore 'red' 'Hello World'}

by kcolby

# re: My First PowerShell Script@ Friday, July 11, 2008 11:30 AM

FYI this first script is just a joke. i am actually working on a real script that i hope to post later today :-P

# re: My First PowerShell Script@ Friday, July 11, 2008 11:38 AM

Actually your script is completly different then mine. I count down from 100 then say hello world.

Yours just displays hello world 100 times

# re: My First PowerShell Script@ Friday, July 11, 2008 12:01 PM

I should see if i can script some better reading comprehension! You're completely right.

SO..

1..100 | %{ write-host "$_"}; Write-host -Fore 'red' 'Hello World'

Embracing the Pipeline is the first step to mastering Powershell

by kcolby