![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | 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) | ||||||||||||
| Guest | Re: PS WMI problem remotely Thomas Makro wrote:
I've just emailed /\/\o\/\/ about this issue... Marco | ||||||||||||
My System Specs![]() | |||||||||||||
| | #3 (permalink) | ||||||||||||||||||||||||
| Guest | 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:
| ||||||||||||||||||||||||
My System Specs![]() | |||||||||||||||||||||||||
| | #4 (permalink) | ||||||||||||||||||||||||
| Guest | Re: PS WMI problem remotely On 15 Mar, 12:26, RichS <Ri...@xxxxxx> wrote:
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.
Best regards, Thomas | ||||||||||||||||||||||||
My System Specs![]() | |||||||||||||||||||||||||
| | #5 (permalink) | ||||||||||||||||||||||||
| Guest | Re: PS WMI problem remotely Marco Shaw [MVP] wrote:
anything I could do to understand the issue/problem. Marco | ||||||||||||||||||||||||
My System Specs![]() | |||||||||||||||||||||||||
| | #6 (permalink) | ||||||||||||||||||||||||||||||||||||
| Guest | 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
| ||||||||||||||||||||||||||||||||||||
My System Specs![]() | |||||||||||||||||||||||||||||||||||||
| | #7 (permalink) | ||||||||||||
| Guest | Re: PS WMI problem remotely On Mar 18, 9:47 pm, Shay Levi <n...@xxxxxx> wrote:
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 | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Can't connect remotely | Don_M | Vista networking & sharing | 1 | 07-06-2008 01:12 PM |
| Accessing Mail remotely | Mike H | Vista mail | 1 | 03-01-2008 09:21 AM |
| Run Dcpromo remotely | Santhosh | PowerShell | 8 | 01-26-2008 06:01 AM |
| Printing Remotely | Dan | Vista print fax & scan | 0 | 11-23-2007 11:41 AM |
| connecting to a pc remotely... | maya | Vista General | 3 | 08-01-2007 06:04 PM |