2,000 대의 컴퓨터를 검사해야하기 때문에 디스크 SMART prefail 상태를 확인하는 스크립트의 속도를 높이려고합니다. 그러나 스크립트는 여전히 동일한 디스크에 대한 상태를 기록하고 있습니다 - "hostname1"및 "hostname2"컴퓨터는 서로 다른 디스크를 가지고 있습니다.워크 플로우에 대한 기능 만들기 - Powershell
function disk-status(){
param(
[Parameter(Mandatory=$true)][string]$computername
)
$WMI = Get-WMIObject -Class Win32_DiskDrive
ForEach ($Drive in $WMI){
$disk = $Drive.Caption
$status = $Drive.Status
#condition will be changed to "-notmatch"
if ($status -match "OK"){
#I'm using write-output to see if the script works during testing
Write-output $computername $disk $status
}
}
}
workflow Get-disk-status {
param(
[string[]]$computers
)
foreach -parallel ($computer in $computers) {
disk-status -computername $computer
}
}
#in the final version I'm going to use get-adcomputer
$computers = "hostname1", "hostname2"
Get-disk-status $computers
출력 내가 얻을 :
는hostname1
ST500LM0 21-1KJ152 SCSI Disk Device
OK
hostname2
ST500LM0 21-1KJ152 SCSI Disk Device
OK
는 아무도 나에게 그것을 해결하는 방법을 적어도 힌트를 줄 수 있습니까? 미리 감사드립니다.
'$ WMI = Get-WMIObject -Class Win32_DiskDrive'를'$ WMI = Get-WMIObject -Class Win32_DiskDrive -ComputerName $ computername'으로 변경해보십시오. – ShanayL
컴퓨터 이름을'Get-WMIObject'에 전달해야합니다. 이렇게 :'$ WMI = Get-WMIObject -Class Win32_DiskDrive -ComputerName $ computername' –