当无法访问远程系统时,是否可以缩短超时时间?

我有一个脚本可以在特定子网上的约600个系统上运行。我正在收集systeminfo并检查TPM状态。我有一个.txt文件,其中包含要检查的所有Windows 10系统的名称。问题是,对于无法访问的每个系统(关闭电源等),在脚本转到下一个系统之前,超时时间很长。这可能会花费非常长的时间。有没有办法限制此超时时间?例如,如果系统在2秒钟内没有响应,它将跳至下一个。

$exportString = ""
foreach ($computersystem in Get-Content C:\Scripts\tpmmachines.txt) {
    $computerinfo = Get-Wmiobject -ComputerName $computersystem Win32_ComputerSystem
    $computerBIOS = Get-Wmiobject -ComputerName $computerSystem Win32_BIOS
    $computerOS = Get-Wmiobject -ComputerName $computerSystem Win32_OperatingSystem
    $tpm = Get-Wmiobject -Class Win32_Tpm -Namespace root\CIMV2\Security\microsoftTpm -ComputerName $computerSystem -Authentication PacketPrivacy |
           Select-Object IsEnabled_InitialValue,ManufacturerId,ManufacturerVersion,ManufacturerVersionInfo,PhysicalPresenceVersionInfo,SpecVersion
    "System Information for: " + $computerinfo.Name
    ""
    "Manufacturer: " + $computerinfo.Manufacturer
    "Model: " + $computerinfo.Model
    "Serial Number: " + $computerBIOS.SerialNumber
    "Bios Version: " + $computerBIOS.Version
    "TPM OEM ID: " + $tpm.ManufacturerId
    "TPM OEM Ver: " + $tpm.ManufacturerVersion
    "TPM Enabled: " + $tpm.IsEnabled_InitialValue
    "Operating System: " + $computerOS.caption + ",Service Pack: " + $computerOS.ServicePackMajorVersion

    "User logged In: " + $computerinfo.username
    "Last Reboot: " + $computerinfo.ConvertToDateTime($computerOS.LastBootUpTime)
    ""
    ""
    $exportString += "System Information for: $($computerinfo.Name)`n`n Model: $($computerinfo.Model)`n Serial Number: $($computerBIOS.SerialNumber)`n Bios Version: $($computerBIOS.Version)`n TPM OEM ID: $($tpm.ManufacturerID)`n TPM OEM Ver: $($tpm.ManufacturerVersion)`n TPM Enabled: $($tpm.IsEnabled_InitialValue)`n Operating System: $($computerOS.caption),Service Pack: $($computerOS.ServicePackMajorVersion)`n User logged In: $($computerinfo.username)`n Last Reboot: $($computerinfo.ConvertToDateTime($computerOS.LastBootUpTime))`n`n`n"
}
$exportString | Out-File -FilePath C:\scripts\TPM.txt

我的预期结果是加快无法访问系统的超时,并减少该脚本在Get-Content文件中的所有系统上运行所花费的时间。对于每个超时的系统,最终超时并接收以下错误消息最多需要20-30秒:

Get-Wmiobject : The RPC server is unavailable.
At line:4 char:17
+ ... puterinfo = Get-Wmiobject -ComputerName $computersystem Win32_Compute
jf5437 回答:当无法访问远程系统时,是否可以缩短超时时间?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3151740.html

大家都在问