Reply To: Windows PowerShell
HOME › Forums › Technology › Windows PowerShell › Reply To: Windows PowerShell
here are some tips for every-day tricks.
1. Learn how to use Get-Member
So let’s say you set a thing to some stuff. Like $thing = get().Stuff
Then you type:
$thing | Get-Member
and look if there’s stuff inside of thing.
also just type $thing and hit enter to see if it’s a variable or whatever
2. calling a value inside of a variable doesn’t always work like normal
so let’s say $thing has three values in it. We’ll call them stuff1, stuff2, and stuff3
so you want stuff3. You would think that you can do this:
$thing.stuff3
but that doesn’t always work. sometimes you have to do this:
$($thing.stuff4)
3. this tip works for ALL programming languages
-learn how to create and use arrays.
-then learn how to use “for i =” and “for each” loops.
“for each” is the easy way, quick to code. but not as robust as a “for i =” loop.
– say $thing.stuff2 you got has this when you do get member {bla bla bla}, there’s probably and array in there. you can do foreach $bla in $thing.stuff2, but you couldn’t say.. have ANOTHER array you are referencing at the same time.
like… so:
$customList[i] = $thing.stuff2[i]
this last one is kinda vague and doesn’t have immediate purpose, but when you start learning it, treat it like the super awesome funky candy it is.