![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
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.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #2 (permalink) |
| Guest
Posts: n/a
| Re: not using variables "IT Staff" <jkklim@hotmail.com> wrote in message news:eCQ8aiGNHHA.1280@TK2MSFTNGP04.phx.gbl... > $today=get-date > write-host "`nToday Date :" $today > > the above works fine. > > However i wish to shorten the code to : > > write-host "`nToday Date :" + get-date > > but i could not get-date ...in vbscript we can use & to concantenate, pls > advice Once you have started a string like this, the PowerShell parser is operation in expression mode so it won't interpret "get-date" as go execute the command get-date. You can instruct the parser to begin a new parser context to get it to intrepret get-date as a command like so: "`nToday Date :" + (get-date) But another, more terse way to do this is to do the expansion within the string using a subexpression like so: "`nToday Date : $(get-date)" -- Keith |
| |
| |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| $Variables | Guy Thomas | PowerShell | 5 | 06-01-2007 05:05 AM |
| Re: list env variables | Keith Hill | PowerShell | 4 | 01-04-2007 11:23 AM |
| Should this work with variables | Marco Shaw | PowerShell | 2 | 12-04-2006 10:29 AM |
| Sundeep Raina(Iopsis): Is variables being handled in Workflow and How to declare New Variables | sunny | Avalon | 0 | 06-30-2006 01:31 AM |