Commiserations. I can relate to this, and the late nights of learning new technologies for the next conference call. Hopefully, this forum will serve you well; and in time, you can give back your experiences.
Learning how to select array members should come after PowerShell basics as terminology can throw off the conversation. “Sort out the non-security categories” would conjure other types of data actions for folks. Plow through blogs and videos to find good resources that “teach instead of show”. As I am an INTJ personality, I checkout books from the library and buy the good ones.
The knowledge and skills you might have from other programming languages should speed you along with PowerShell. Once you get a foundation in the syntax, you can build on that to learn when to use certain loops, cmdlets, custom functions, and so forth. For example, +=
becomes costly when working with large data sets (!! Active Directory !!), and an alternative might be required. Before too long, you might be helping someone decipher something like the following:
$x = New-Object 'object[,]' 2,3;
$x[0,0] = ('up','charm','top')
$x[0,1] = ('Alice','Bob')
$x[0,2] = ('electron','muon','tau')
$x[1,0] = ('down','strange','bottom')
$x[1,2] = ('e-neutrino','m-neutrino','t-neutrino')
for($i=0;$i -lt $x[0,0].length;$i++)
{
Write-Host $x[0,$i] $x[1,$i]
}
–If you like maths, that’s a 2x3 matrix. The clever eye will notice something collectively funky about that matrix, too.
Now, I threw that bit of over-the-top-not-your-solution code in for a double purpose (triple—when you consider my ego). It shows what PowerShell is capable of in terms of data modeling. It might look odd, but it’s only a grid overlaid with some PowerShell populations. We return the grid elements using a FOR loop (there’s that .length
method again).
And this brings me to:
I’m only trying to obtain sec.business and filter out the others in order to inject it into a variable that I will use later for an ADGroup and ADGroupMember cmdlet.
Give me some time to figure out how to present this while you chase down some syntax and terms.
Observe, research, smash with a hammer, analyze; observe, research, smash…
See also