PowerShell/CLI: “Foreach” loop with multiple arrays -


i'm trying brain round , on verge of head explosion. have list of data listing usernames, , virtual machines.

for example:

username      servername bob.lazar     abc001 bob.lazar     abc002 peter.bob     ght004 bob.lazar     abc006 

i need collate user data can email them listing. if loop through , email mail bob 3x times, need email bob once 3 server names. assume need put data multidimential array , loop through don't know begin.

i didn't understand problem i'm pretty sure looking group cmdlet. pipe collection , specify property want group things , elements available group property

jps> dir |group extension |? name -eq ".txt" | % group       directory: c:\temp   mode                lastwritetime         length name ----                -------------         ------ ---- -a----         6/2/2016   8:23 pm          57930 foo.txt -a----       12/21/2015   8:00 pm           8265 modulesessions.ps1.t -a----        3/15/2016   6:26 pm             51 num.txt -a----         6/6/2015   6:55 pm           2390 t2.txt 

alternatively, can use -ashashtable return hashtable property key

jps> (dir |group extension -ashashtable)[".txt"]       directory: c:\temp   mode                lastwritetime         length name ----                -------------         ------ ---- -a----         6/2/2016   8:23 pm          57930 foo.txt -a----       12/21/2015   8:00 pm           8265 modulesessions.ps1.txt -a----        3/15/2016   6:26 pm             51 num.txt -a----         6/6/2015   6:55 pm           2390 t2.txt 

experiment those.


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -