2016-06-07 6 views
2

PowerShell을 배우려고합니다. Exchange 서버를 모니터링하기위한 작은 스크립트를 작성했습니다. 문제Where-Object는 로컬에서는 작동하지만 원격으로는 작동하지 않습니다.

Get-WmiObject -Class win32_volume -Filter 'drivetype = 3' | Where-Object 'Label' -ne "System Reserved" | ft SystemName, DriveLetter, Label, @{LABEL='FreeSpaceGB'; EXPRESSION={"{0:N0}" -f ($_.freespace/1GB)}} 

않고 ​​있지만 경우 로컬 컴퓨터에서이 선 작업 내가 호출-명령에 동일한 코드를 넣어 이유를 이해할 수없는 나는이 오류가 발생합니다.

Invoke-Command -ComputerName $server -credential $c -ScriptBlock { 
    Get-WmiObject -Class win32_volume -Filter 'drivetype = 3' | Where-Object 'Label' -ne "System Reserved" | ft SystemName, DriveLetter, Label, @{LABEL='FreeSpaceGB'; EXPRESSION={"{0:N0}" -f ($_.freespace/1GB)}} 
    } 

은 널 (null)이기 때문에 'FilterScript를'매개 변수 인수를 결합 할 수 없습니다. + CategoryInfo : InvalidData : (:) [어디-오브젝트, ParameterBindingValidationException + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed, Microsoft.PowerShell.Commands.WhereObject 내가 운이없이 생각할 수있는 모든 노력을

명령. gm으로 확인해도 레이블에 존재합니다 ... 어떤 팁 ..?

+0

내가보기 엔 PowerShell을의 최신 버전을 권장합니다. BIG 경우, 일부 버전은 특정 버전의 Exchange와 호환되지 않으므로 –

답변

2

연결하려는 끝점이 단순화 된 Where-object 구문이없는 PowerShell 2.0 인 것처럼 보입니다.

대신이 곳 객체를보십시오 : 당신이 할 수있는 경우

Where-Object {$_.Label -ne "System Reserved"} 
+0

작동. 감사. 나는 PS 버전 불일치에 대해 생각하지 않았다. – Micael

관련 문제