Solved

Combine Vars in Powershell into new Var

Posted on 2011-03-17
3
656 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 69

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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

The article will show you how you can maintain a simple logfile of all Startup and Shutdown events on Windows servers and desktops with PowerShell. The script can be easily adapted into doing more like gracefully silencing/updating your monitoring s…
Synchronize a new Active Directory domain with an existing Office 365 tenant
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

803 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