I swear I'm missing something easy here...
Here's a simple script to get disk info:
function get-disks {
try { $disks = gwmi win32_logicaldisk -co $server}
catch { write "$server : Can't connect"}
}
get-disks
$disk.deviceid
The gwmi command alone works perfectly. The "$disks = gwmi..." command alone works perfectly. The try {...}catch{...} lines run alone work perfectly.
But as soon as I load the function and call 'get-disks' I receive no errors, but $disks is empty.