![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | not using variables $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 |
My System Specs![]() |
| | #2 (permalink) |
| | 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 |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| SQL query with PS variables | PowerShell | |||
| math with "GB/MB/KB" in variables fails, without variables works? | PowerShell | |||
| $Variables | PowerShell | |||