Hello all,
Writing (what should be) a relatively simple script in Powershell, in fact the first useful thing I've tried to write, and I'm running into a few problems. Ideally, this script should get a list of all of the Mount Points on a machine from Win32_Volume and store them in a variable, then query Win32_PerfFormattedData_PerfDisk_LogicalDisk to find the free space on them and report it back. I'm running into two problems at this point:
1) The compound statements in my where-object clause aren't working
2) The variables in the array are passing through as @(%var%) instead of just %var% which is problematic when using my where-object clause in the second line.
$mounteddrives = @(get-wmiobject -namespace "root\cimv2" -class "win32_volume" | where-object {$_.DriveLetter -eq $null -AND $_.SystemVolume -eq "False"} | Select -Property Name)
ForEach ($mp in $mounteddrives) {get-wmiobject -namespace "root\cimv2" -class "Win32_PerfFormattedData_PerfDisk_LogicalDisk" | where-object {$_.name -match $mp}}
I suppose its possible I'm going about this all wrong, but figured I'd ask for a bit of assistance here on the chance I might just need to change something simple. Thanks for any assistance.