![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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) |
| | PS WMI problem remotely Hi everybody. The PS script located at <http://thepowershellguy.com/blogs/po.../01/29/nested- relative-wmi-queries-in-powershell.aspx> ....works fine locally. However, when I replace the dot with the name of a remote computer, I get this error: An error occurred while enumerating through a collection: Not supported . At C:\Usenet.ps1:23 char:2 + $ <<<< s.get()|% { How can I solve this? Regards, Thomas |
My System Specs![]() |
| | #2 (permalink) |
| | Re: PS WMI problem remotely Thomas Makro wrote: Quote: > Hi everybody. > > The PS script located at > <http://thepowershellguy.com/blogs/po.../01/29/nested- > relative-wmi-queries-in-powershell.aspx> > ...works fine locally. However, when I replace the dot with the name > of a remote computer, I get this error: > > An error occurred while enumerating through a collection: Not > supported . > At C:\Usenet.ps1:23 char:2 > + $ <<<< s.get()|% { > > How can I solve this? I've just emailed /\/\o\/\/ about this issue... Marco |
My System Specs![]() |
| | #3 (permalink) |
| | Re: PS WMI problem remotely My first questions would be: 1) does the $drives variable get populated against the remote machine 2) How does $s and $s2 know they are working againsta a remote machine. Is it implicit in the objects or do they have to be told? -- Richard Siddaway Please note that all scripts are supplied "as is" and with no warranty Blog: http://richardsiddaway.spaces.live.com/ PowerShell User Group: http://www.get-psuguk.org.uk "Marco Shaw [MVP]" wrote: Quote: > Thomas Makro wrote: Quote: > > Hi everybody. > > > > The PS script located at > > <http://thepowershellguy.com/blogs/po.../01/29/nested- > > relative-wmi-queries-in-powershell.aspx> > > ...works fine locally. However, when I replace the dot with the name > > of a remote computer, I get this error: > > > > An error occurred while enumerating through a collection: Not > > supported . > > At C:\Usenet.ps1:23 char:2 > > + $ <<<< s.get()|% { > > > > How can I solve this? > I've confirmed this using the v2 CTP and quering a remote Vista SP1 box. > I've just emailed /\/\o\/\/ about this issue... > > Marco > |
My System Specs![]() |
| | #4 (permalink) |
| | Re: PS WMI problem remotely On 15 Mar, 12:26, RichS <Ri...@xxxxxx> wrote: Quote: > My first questions would be: > > 1) does the $drives variable get populated against the remote machine Code Editor, I see that $drives refer to the remote computer. This is as expected. And so does $qPartition's property "SourceObject". However, both the $s and $s2, refer to the localhost (\\.\root\cimv2). I'm not sure how the System.Management.ManagementObjectSearcher works, but this looks suspicious. Quote: > 2) How does $s and $s2 know they are working againsta a remote machine. Is > it implicit in the objects or do they have to be told? Best regards, Thomas |
My System Specs![]() |
| | #5 (permalink) |
| | Re: PS WMI problem remotely Marco Shaw [MVP] wrote: Quote: > Thomas Makro wrote: Quote: >> Hi everybody. >> >> The PS script located at >> <http://thepowershellguy.com/blogs/po.../01/29/nested- >> relative-wmi-queries-in-powershell.aspx> >> ...works fine locally. However, when I replace the dot with the name >> of a remote computer, I get this error: >> >> An error occurred while enumerating through a collection: Not >> supported . >> At C:\Usenet.ps1:23 char:2 >> + $ <<<< s.get()|% { >> >> How can I solve this? > I've confirmed this using the v2 CTP and quering a remote Vista SP1 box. > I've just emailed /\/\o\/\/ about this issue... > > Marco anything I could do to understand the issue/problem. Marco |
My System Specs![]() |
| | #6 (permalink) |
| | Re: PS WMI problem remotely Set the Scope member for each ManagementObjectSearcher object: $s = New-Object System.Management.ManagementObjectSearcher $s.Scope = "\\$computer\root\cimv2" $s2 = New-Object System.Management.ManagementObjectSearcher $s2.Scope = "\\$computer\root\cimv2" ----- Shay Levi $cript Fanatic http://scriptolog.blogspot.com Quote: > On 15 Mar, 12:26, RichS <Ri...@xxxxxx> wrote: > Quote: >> My first questions would be: >> >> 1) does the $drives variable get populated against the remote machine >> > Code Editor, I see that $drives refer to the remote computer. This is > as expected. > And so does $qPartition's property "SourceObject". > However, both the $s and $s2, refer to the localhost (\\.\root\cimv2). > I'm not sure how the System.Management.ManagementObjectSearcher works, > but this looks suspicious. Quote: >> 2) How does $s and $s2 know they are working againsta a remote >> machine. Is it implicit in the objects or do they have to be told? >> > > Best regards, Thomas > |
My System Specs![]() |
| | #7 (permalink) |
| | Re: PS WMI problem remotely On Mar 18, 9:47 pm, Shay Levi <n...@xxxxxx> wrote: Quote: > $s = New-Object System.Management.ManagementObjectSearcher > $s.Scope = "\\$computer\root\cimv2" > $s2 = New-Object System.Management.ManagementObjectSearcher > $s2.Scope = "\\$computer\root\cimv2" Now, when everything works, in case somebody should be interested, here's the new version of the script: $computer = '.' $drives = Get-WmiObject Win32_DiskDrive -ComputerName $computer $s = New-Object System.Management.ManagementObjectSearcher $s.Scope = "\\$computer\root\cimv2" $s2 = New-Object System.Management.ManagementObjectSearcher $s2.Scope = "\\$computer\root\cimv2" $qPartition = new-object System.Management.RelatedObjectQuery $qPartition.RelationshipClass = 'Win32_DiskDriveToDiskPartition' $qLogicalDisk = new-object System.Management.RelatedObjectQuery $qLogicalDisk.RelationshipClass = 'Win32_LogicalDiskToPartition' $drives |% { "Physical Disk:" + $_.Caption $qPartition.SourceObject = $_ $s.Query= $qPartition $s.get()|% { " Disk Partition:" + $_.DeviceID $qLogicalDisk.SourceObject = $_ $s2.query= $qLogicalDisk $s2.get()|% { " Logical Disk:" + $_.deviceid } } } And a few comments: All disks are enumerated using the above WMI statements, including USB removable drives. This can be changed by modifying one of the WMI statements. For the Win32_DiskDrive class, there are a couple of solutions: -filter "MediaType='Fixed hard disk media'" -filter "InterfaceType='IDE'" #and/or SCSI Best regards, Thomas |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Problem using EnableStatic to remotely set IP address | PowerShell | |||
| execution policy problem executing remotely with hpc job scheduler | PowerShell | |||
| problem with running script remotely - ODBC connection - ORACLE DB | VB Script | |||
| Problem reading registry remotely | PowerShell | |||
| Can't connect remotely | Vista networking & sharing | |||