I'm trying to do this efficiently, as I've already accomplished this in a not-so-elegant way.
Using the command "Get-QADComputer" from Quest AD Snapin and specifying the scope then doing a pipe and "select-object -property name", I end up with a nice little array full of computer names and related properties from AD. When I attempt to use the name as a Get-WMIObject -computer <computer name>, it's not working so well.
It comes out like @{Name=<computername>} and I have to do an old-fashioned text parse to get it to work. I don't think this is necessary in Powershell. In VBScript it would be though.
Currently, I've tried various ways to do this. I have a subroutine set up for a command like
getdrive $computer, but that's after I've parsed the names from their old form of @{Name=}. I'm trying to find a one liner:
Get-QADComputer -scope <domain> | ?{getdrive $_}
My Function for the GetDrive is something along the lines of
Function Getdrive{
$ColDisks = Get-WMIObject W32Logicaldisk -computername $args
<more code>
}
So, I can't do a one liner for the Get-WMIObject because I have quite a bit of code needing to processed in my function... or can I?
Any help?
Start Free Trial