Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Combine Vars in Powershell into new Var

Posted on 2011-03-17
3
Medium Priority
?
666 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
3 Comments
 
LVL 71

Accepted Solution

by:
Qlemo earned 2000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Previously, on our Nano Server Deployment series, we've created a new nano server image and deployed it on a physical server in part 2. Now we will go through configuration.
In the absence of a fully-fledged GPO Management product like AGPM, the script in this article will provide you with a simple way to watch the domain (or a select OU) for GPOs changes and automatically take backups when policies are added, removed o…
Loops Section Overview
Screencast - Getting to Know the Pipeline

885 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