Skip to content

Instantly share code, notes, and snippets.

@martin9700
Created January 12, 2014 20:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save martin9700/8390269 to your computer and use it in GitHub Desktop.
Save martin9700/8390269 to your computer and use it in GitHub Desktop.
#Validate sources
Write-Host "Validating sources...`n"
$Keep = @()
ForEach ($Source in $Sources)
{ Write-host "$Source..." -NoNewline
If (-not (Get-WmiObject "Win32_ComputerSystem" -ComputerName $Source -ErrorAction SilentlyContinue))
{ #Are you sure?
Start-Sleep -Milliseconds 500
If (-not (Get-WmiObject "Win32_ComputerSystem" -ComputerName $Source -ErrorAction SilentlyContinue))
{ Write-Host "BAD" -ForegroundColor Red
Write-Warning "$($Error[0])"
Write-Warning "Removing $Source from Source list"
}
Else
{ Write-Host "OK"
$Keep += $Source
}
}
Else
{ Write-Host "OK"
$Keep += $Source
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment