Необходимо добавить командлет If (Test-Connection) - PullRequest
0 голосов
/ 21 февраля 2020

Можно ли добавить командлет If (Test-Connection) в этот сценарий? Я хочу сначала пропинговать хост, запустить скрипт, если хост включен.

`enter code here`

    $sb = { write-host "$env:computername"

    Get-ChildItem HKLM:\SOFTWARE\McAfee\AVSolution\DS\ -Recurse | ForEach-Object {

    Get-ItemProperty $_.pspath
    }
    }
    $Results = Invoke-Command -ScriptBlock $sb -ComputerName (Get-Content -Path 'C:\computers.txt')

    #Show output to screen

    Write-Output $Results

    $Results | Export-Csv -Path 'C:\computers.CSV' -NoTypeInformation -Append
...