![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | How to aggregate, unify results from many tables Hello, I explane below my "problem". I have a powershell script that check volume disk information. It takes server names from a text file. So I have something like this: ------------------- foreach ($server in $servers) { $outData = Get-WmiObject -Class Win32_Volume -ComputerName $server | Select-Object DriveLetter,SerialNumber,Name,Label,Capacity,Freespace | Sort-Object Freespace $retData += $outData } $outData | ft ------------------- as result I see many tables as the numbers of servers listed into text file. So is there a way to unify all data into only one table ? Thanks a lot. Bye, Luca |
My System Specs![]() |
| | #2 (permalink) |
| | Re: How to aggregate, unify results from many tables Hi Luca, See if this works for you: Get-WmiObject Win32_Volume -computer (get-content servers.txt) | select SystemName,DriveLetter,SerialNumber,Name,Label,Capacity,Freespace | sort Freespace | ft --- Shay Levy Windows PowerShell MVP blog: http://blogs.microsoft.co.il/blogs/ScriptFanatic LF> Hello, LF> I explane below my "problem". LF> I have a powershell script that check volume disk information. It LF> takes LF> server names from a text file. LF> So I have something like this: LF> ------------------- LF> foreach ($server in $servers) LF> { LF> $outData = Get-WmiObject -Class Win32_Volume -ComputerName $server | LF> Select-Object DriveLetter,SerialNumber,Name,Label,Capacity,Freespace LF> | LF> Sort-Object Freespace LF> $retData += $outData LF> LF> } LF> LF> $outData | ft LF> ------------------- LF> as result I see many tables as the numbers of servers listed into LF> text file. So is there a way to unify all data into only one table ? LF> LF> Thanks a lot. LF> LF> Bye, Luca LF> |
My System Specs![]() |
| | #3 (permalink) |
| | Re: How to aggregate, unify results from many tables Hi Shay, first of all...thank you for reply. I specify you that into "servers.txt" file there isn't only server names but also other information like what volume needs to check and what is the limit size; then I parse the txt file by extracting server name ($server), volume name ($volumeName) and limit ($volumeLimit) to check. Example of servers.txt: SERVERNAME|S:\!4GB So the entire WMI query is: --------------------------- foreach ($line in $contentFile) { ....[Parsing Data]... $outData = Get-WmiObject -Class Win32_Volume -ComputerName $server | Where-Object {$_.DriveType -eq 3 -and $_.Name -eq $volumeName -and $_.Freespace -le $volumeLimit} | Select-Object DriveLetter,SerialNumber,Name,Label,Capacity,Freespace | Sort-Object Freespace $retData += $outData } $outData | ft --------------------------- So, my question is always the same:there a way to unify all data into only one table ? Thanks a lot. "Shay Levy [MVP]" <no@xxxxxx> ha scritto nel messaggio news:89228ed234e718cab09690fdc24f@xxxxxx Quote: > Hi Luca, > > > See if this works for you: > > Get-WmiObject Win32_Volume -computer (get-content servers.txt) | select > SystemName,DriveLetter,SerialNumber,Name,Label,Capacity,Freespace | sort > Freespace | ft > > > > --- > Shay Levy > Windows PowerShell MVP > blog: http://blogs.microsoft.co.il/blogs/ScriptFanatic > > > > LF> Hello, > LF> I explane below my "problem". > LF> I have a powershell script that check volume disk information. It > LF> takes > LF> server names from a text file. > LF> So I have something like this: > LF> ------------------- > LF> foreach ($server in $servers) > LF> { > LF> $outData = Get-WmiObject -Class Win32_Volume -ComputerName $server | > LF> Select-Object DriveLetter,SerialNumber,Name,Label,Capacity,Freespace > LF> | > LF> Sort-Object Freespace > LF> $retData += $outData > LF> LF> } > LF> LF> $outData | ft > LF> ------------------- > LF> as result I see many tables as the numbers of servers listed into > LF> text file. So is there a way to unify all data into only one table ? > LF> LF> Thanks a lot. > LF> LF> Bye, Luca > LF> > |
My System Specs![]() |
| | #4 (permalink) |
| | Re: How to aggregate, unify results from many tables Hi Shay, first of all...thank you for reply. I specify you that into "servers.txt" file there isn't only server names but also other information like what volume needs to check and what is the limit size; then I parse the txt file by extracting server name ($server), volume name ($volumeName) and limit ($volumeLimit) to check. Example of servers.txt: SERVERNAME|S:\!4GB So the entire WMI query is: --------------------------- foreach ($line in $contentFile) { ....[Parsing Data]... $outData = Get-WmiObject -Class Win32_Volume -ComputerName $server | Where-Object {$_.DriveType -eq 3 -and $_.Name -eq $volumeName -and $_.Freespace -le $volumeLimit} | Select-Object DriveLetter,SerialNumber,Name,Label,Capacity,Freespace | Sort-Object Freespace $retData += $outData } $outData | ft --------------------------- So, my question is always the same:there a way to unify all data into only one table ? Thanks a lot. "Shay Levy [MVP]" <no@xxxxxx> ha scritto nel messaggio news:89228ed234e718cab09690fdc24f@xxxxxx Quote: > Hi Luca, > > > See if this works for you: > > Get-WmiObject Win32_Volume -computer (get-content servers.txt) | select > SystemName,DriveLetter,SerialNumber,Name,Label,Capacity,Freespace | sort > Freespace | ft > > > > --- > Shay Levy > Windows PowerShell MVP > blog: http://blogs.microsoft.co.il/blogs/ScriptFanatic > > > > LF> Hello, > LF> I explane below my "problem". > LF> I have a powershell script that check volume disk information. It > LF> takes > LF> server names from a text file. > LF> So I have something like this: > LF> ------------------- > LF> foreach ($server in $servers) > LF> { > LF> $outData = Get-WmiObject -Class Win32_Volume -ComputerName $server | > LF> Select-Object DriveLetter,SerialNumber,Name,Label,Capacity,Freespace > LF> | > LF> Sort-Object Freespace > LF> $retData += $outData > LF> LF> } > LF> LF> $outData | ft > LF> ------------------- > LF> as result I see many tables as the numbers of servers listed into > LF> text file. So is there a way to unify all data into only one table ? > LF> LF> Thanks a lot. > LF> LF> Bye, Luca > LF> > |
My System Specs![]() |
| | #5 (permalink) |
| | Re: How to aggregate, unify results from many tables I would go with the foreach cmdlet instead, the foreach loop is not that pipeline friendly. Notice that I also used WMI serverside filtering (with the -filter parameter) making the query run on the remote server, returning only the relvant items instead of getting all objects to the client anf then filtering with the where cmdlet: $contentFile | foreach { ...[Parsing Data]... Get-WmiObject -Class Win32_Volume -ComputerName $server -filter "DriveType=3 and Name='$volumeName' -and Freespace < $volumeLimit" } | select SystemName,DriveLetter,SerialNumber,Name,Label,Capacity,Freespace } | sort Freespace | ft --- Shay Levy Windows PowerShell MVP blog: http://blogs.microsoft.co.il/blogs/ScriptFanatic LF> Hi Shay, LF> first of all...thank you for reply. LF> I specify you that into "servers.txt" file there isn't only server LF> names but LF> also other information like what volume needs to check and what is LF> the limit LF> size; then I parse the txt file by extracting server name ($server), LF> volume LF> name ($volumeName) and limit ($volumeLimit) to check. LF> Example of servers.txt: LF> LF> SERVERNAME|S:\!4GB LF> LF> So the entire WMI query is: LF> LF> --------------------------- LF> foreach ($line in $contentFile) LF> { LF> ...[Parsing Data]... LF> LF> $outData = Get-WmiObject -Class Win32_Volume -ComputerName $server | LF> Where-Object {$_.DriveType -eq 3 -and $_.Name -eq $volumeName -and LF> $_.Freespace -le $volumeLimit} | LF> Select-Object DriveLetter,SerialNumber,Name,Label,Capacity,Freespace LF> | LF> Sort-Object Freespace LF> $retData += $outData LF> } LF> $outData | ft LF> --------------------------- LF> So, my question is always the same:there a way to unify all data LF> into only one table ? LF> LF> Thanks a lot. LF> LF> "Shay Levy [MVP]" <no@xxxxxx> ha scritto nel messaggio LF> news:89228ed234e718cab09690fdc24f@xxxxxx LF> Quote: Quote: >> Hi Luca, >> >> See if this works for you: >> >> Get-WmiObject Win32_Volume -computer (get-content servers.txt) | >> select >> SystemName,DriveLetter,SerialNumber,Name,Label,Capacity,Freespace | >> sort Freespace | ft >> >> --- >> Shay Levy >> Windows PowerShell MVP >> blog: http://blogs.microsoft.co.il/blogs/ScriptFanatic >> LF> Hello, >> LF> I explane below my "problem". >> LF> I have a powershell script that check volume disk information. It >> LF> takes >> LF> server names from a text file. >> LF> So I have something like this: >> LF> ------------------- >> LF> foreach ($server in $servers) >> LF> { >> LF> $outData = Get-WmiObject -Class Win32_Volume -ComputerName >> $server | >> LF> Select-Object >> DriveLetter,SerialNumber,Name,Label,Capacity,Freespace >> LF> | >> LF> Sort-Object Freespace >> LF> $retData += $outData >> LF> LF> } >> LF> LF> $outData | ft >> LF> ------------------- >> LF> as result I see many tables as the numbers of servers listed into >> LF> text file. So is there a way to unify all data into only one >> table ? >> LF> LF> Thanks a lot. >> LF> LF> Bye, Luca >> LF> |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Using Tables within emails | Vista mail | |||
| Gridview with more than 2 tables | .NET General | |||
| Multiple tables | .NET General | |||
| tables in wlm | Live Mail | |||
| Hash Tables | PowerShell | |||