Powershell: two variables from one user input?

PliotronX

Diamond Member
Oct 17, 1999
8,883
107
106
My Googlefu is proving ineffective; I'd like to create two unique variables from one user input. Is that possible? Not a huge deal but just curious.

edit- dummkopf, I just made string2 equal to string1 however, the ultimate goal is to apply toLower() to string2 and it does not appear to apply because it is probably still just equal to string1.. how does one create the string with "no strings attached?" :D

LOL nevermind about this post, just affixed .toLower() after string2 ... god I'm a goofball.
 
Last edited:

Scarpozzi

Lifer
Jun 13, 2000
26,391
1,780
126
If you ever need to store a string in another variable you can just code another line like this:
code:
$string1 = Read-Host 'Enter a string'
>Enter a string:
>echo $string1
>This is a string.
$string2 = echo $string1
$string2 = $string2.toLower()

>echo $string2
> this is a string.

When using toLower() or -replace, you have to save the data or it doesn't leave the pipeline. You look like you have it. It just takes a while to get used to the quirks. What's more of a struggle is working with arrays and hash tables, but it makes it easy to index large amounts of data if stored correctly in the hash.