Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Function Test-NetStatus
- {
- [CmdletBinding()]
- Param(
- [Parameter(Mandatory=$true,ValueFromPipeLine)][String]$ComputerName)
- Process
- {
- $aaa = "Host is "
- $bbb = " --- "
- $ccc = " -- "
- $result = Test-Connection -ComputerName $ComputerName -Count 1 -Quiet -ErrorAction SilentlyContinue
- If ($result -eq "True") {$result = "Online"}
- Else {$result = "Offline"}
- IF ($result -eq "Online") {Write-host $aaa$result$bbb$computername -ForegroundColor Green}
- Else {Write-host $aaa$result$ccc$computername -ForegroundColor Red}
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement