Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

1..9|%{write-host $_:443}

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 07-20-2007   #1 (permalink)
Guest


 

1..9|%{write-host $_:443}

I haven't found a way to properly escape the ':' character in the following

1..9|%{write-host 10.0.0.$_:443}

1..9|%{write-host 10.0.0.$_} works just fine but even

1..9|%{write-host 10.0.0.$_some arbitrary text} doesn't

anyone have a clue to give me?



My System SpecsSystem Spec
Old 07-20-2007   #2 (permalink)
Jeremiah Buckley
Guest


 

RE: 1..9|%{write-host $_:443}

try 1..9 | %{write-host 10.0.0.`:433}

"Æ" wrote:

> I haven't found a way to properly escape the ':' character in the following
>
> 1..9|%{write-host 10.0.0.$_:443}
>
> 1..9|%{write-host 10.0.0.$_} works just fine but even
>
> 1..9|%{write-host 10.0.0.$_some arbitrary text} doesn't
>
> anyone have a clue to give me?
>
>
>

My System SpecsSystem Spec
Old 07-20-2007   #3 (permalink)
Jeremiah Buckley
Guest


 

RE: 1..9|%{write-host $_:443}

Sorry, I misread what you wanted. This will include $_ value:
1..9 | %{write-host ("10.0.0." + $_ + ":433")}

"Æ" wrote:

> I haven't found a way to properly escape the ':' character in the following
>
> 1..9|%{write-host 10.0.0.$_:443}
>
> 1..9|%{write-host 10.0.0.$_} works just fine but even
>
> 1..9|%{write-host 10.0.0.$_some arbitrary text} doesn't
>
> anyone have a clue to give me?
>
>
>

My System SpecsSystem Spec
Old 07-20-2007   #4 (permalink)
Brandon Shell
Guest


 

Re: 1..9|%{write-host $_:443}

1..9|%{write-host "10.0.0.$($_):443"}

<Æ> wrote in message news:%23qba14uyHHA.1208@TK2MSFTNGP03.phx.gbl...
>I haven't found a way to properly escape the ':' character in the following
>
> 1..9|%{write-host 10.0.0.$_:443}
>
> 1..9|%{write-host 10.0.0.$_} works just fine but even
>
> 1..9|%{write-host 10.0.0.$_some arbitrary text} doesn't
>
> anyone have a clue to give me?
>
>


My System SpecsSystem Spec
Old 07-20-2007   #5 (permalink)
Clint Bergman
Guest


 

Re: 1..9|%{write-host $_:443}

This works:
1..9 | % { Write-Host $("10.0.0.$_"+":443") }

Funny, you would think that the parser would break out of "variable name" with the standard backtick escape
character...hmmm.

--
(^_^)v ~Clint
My (very) humble blogger beginnings:
http://outputredirection.blogspot.com

<Æ> wrote in message news:%23qba14uyHHA.1208@TK2MSFTNGP03.phx.gbl...
>I haven't found a way to properly escape the ':' character in the following
>
> 1..9|%{write-host 10.0.0.$_:443}
>
> 1..9|%{write-host 10.0.0.$_} works just fine but even
>
> 1..9|%{write-host 10.0.0.$_some arbitrary text} doesn't
>
> anyone have a clue to give me?
>
>



My System SpecsSystem Spec
Old 07-20-2007   #6 (permalink)
Kiron
Guest


 

Re: 1..9|%{write-host $_:443}

You can also use a blank space followed by the backspace escape character
(`b) after $_

1..9|%{write-host 10.0.0.$_ `b:443}
1..9|%{write-host 10.0.0.$_ `bsome arbitrary text}

--
Kiron

My System SpecsSystem Spec
Old 07-20-2007   #7 (permalink)
Bruce Payette [MSFT]
Guest


 

Re: 1..9|%{write-host $_:443}

Or:

1..9|%{write-host 10.0.0.${_}:443}

Using the delimited variable syntax where the variable name is enclosed in
braces.

or just quote the colon:

1..9|%{write-host 10.0.0.$_`:443}

-bruce

--
Bruce Payette [MSFT]
Windows PowerShell Technical Lead
Microsoft Corporation
This posting is provided "AS IS" with no warranties, and confers no rights.


"Brandon Shell" <tshell.mask@mk.gmail.com> wrote in message
news:%23qaltCvyHHA.5408@TK2MSFTNGP02.phx.gbl...
> 1..9|%{write-host "10.0.0.$($_):443"}
>
> <Æ> wrote in message news:%23qba14uyHHA.1208@TK2MSFTNGP03.phx.gbl...
>>I haven't found a way to properly escape the ':' character in the
>>following
>>
>> 1..9|%{write-host 10.0.0.$_:443}
>>
>> 1..9|%{write-host 10.0.0.$_} works just fine but even
>>
>> 1..9|%{write-host 10.0.0.$_some arbitrary text} doesn't
>>
>> anyone have a clue to give me?
>>
>>

>



My System SpecsSystem Spec
Old 07-20-2007   #8 (permalink)
Guest


 

Re: 1..9|%{write-host $_:443}

That doesn't work for me.

10.0.0.:433
10.0.0.:433
10.0.0.:433
10.0.0.:433
10.0.0.:433
10.0.0.:433
10.0.0.:433
10.0.0.:433
10.0.0.:433

"Jeremiah Buckley"
> try 1..9 | %{write-host 10.0.0.`:433}



My System SpecsSystem Spec
Old 07-20-2007   #9 (permalink)
Guest


 

Re: 1..9|%{write-host $_:443}

Quoting the colon is what I tried first.

10.0.0.:433
10.0.0.:433
10.0.0.:433
10.0.0.:433
10.0.0.:433
10.0.0.:433
10.0.0.:433
10.0.0.:433
10.0.0.:433

That result surprised me.

"Bruce Payette [MSFT]"
> or just quote the colon:
>
> 1..9|%{write-host 10.0.0.$_`:443}



My System SpecsSystem Spec
Old 07-20-2007   #10 (permalink)
Hecks
Guest


 

RE: 1..9|%{write-host $_:443}

Although this isn't as quick as some of the other suggestions, I've been
using this syntax more and more recently when scripting just because I find
it a bit easier to to read (since variables and formatting info can be
addressed separately):

1..9 | %{write-host ("10.0.0.{0}:443" -f $_)}

-Hecks

"Æ" wrote:

> I haven't found a way to properly escape the ':' character in the following
>
> 1..9|%{write-host 10.0.0.$_:443}
>
> 1..9|%{write-host 10.0.0.$_} works just fine but even
>
> 1..9|%{write-host 10.0.0.$_some arbitrary text} doesn't
>
> anyone have a clue to give me?
>
>
>

My System SpecsSystem Spec
Closed Thread

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
When to use write-host? how to display variable value? PowerShell 1 08-20-2008 03:27 PM
redirect write-host DouglasWoods PowerShell 12 04-26-2007 05:10 PM
Non ASCII characters with write-host Peter Monadjemi PowerShell 6 02-05-2007 02:02 PM
write host color function IT Staff PowerShell 1 01-23-2007 01:46 AM
Write-Host question Doug PowerShell 2 12-20-2006 12:48 PM


Vistax64.com 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 2005-2008

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 47 48 49 50 51