Author Posts

September 1, 2015 at 7:06 am

$a = Get-ADComputer -filter * | select name

$b = ($a|Select -ExpandProperty Name) -join ","

Get-WmiObject -namespace root\wmi –class MSStorageDriver_FailurePredictStatus -ComputerName $b | Select pscomputername, PredictFailure | Format-Table –Autosize

September 1, 2015 at 7:10 am

This bit here:

$b = ($a|Select -ExpandProperty Name) -join ","

Is creating a single string variable which contains a bunch of computer names, separated by commas. What Get-WmiObject actually wants is an array of computer names. This is easy, as all you have to do is get rid of the -join operation (which is what turns an array into a separated string.) This should work:

$b = Get-ADComputer -filter * | select-object -ExpandProperty Name