Solved

Combine Vars in Powershell into new Var

Posted on 2011-03-17
3
659 Views
Last Modified: 2012-06-22
I am trying to combine variables in a script into a single varilabe.

So say My Script has set:
$a =1
$b =hello
$c = World

I want my $result to be "1 hello World"

I tried things like
$result = $a $b $c

So I can just call on $result

Extra credit how do I set the $result to be "1.hello world!"

Thanks
0
Comment
Question by:brittonv
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 70

Accepted Solution

by:
Qlemo earned 500 total points
ID: 35161480
 $a ="1"
 $b ="hello"
 $c ="World"
 $result = $a + " " + $b + " " +$c

Open in new window

 $a ="1"
 $b ="hello"
 $c ="World"
 $result = $a + "." +$b + " " +$c + "!"

Open in new window

0
 
LVL 8

Author Closing Comment

by:brittonv
ID: 35161714
THANK YOU!!!!
0
 
LVL 13

Expert Comment

by:soostibi
ID: 35163777
Or more "powershellish" solution:

$result = "$a $b $c"

and

$result = "$a.$b $c"
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Utilizing an array to gracefully append to a list of EmailAddresses
Windows 10 came with  a lot of built in applications, Some organisations leave them there, some will control them using GPO's. This Article is useful for those who do not want to have any applications in their image (example:me).
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

628 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question