Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

What is another way to verify a machine is offline other than using test-connection

$
0
0

This is the script that I have

Import-Module activedirectory
$rtn = $null
$time = (Get-Date).AddDays(-30)

Get-ADComputer -Filter {modified -lt $time -and OperatingSystem -like 'Windows 7*'}|ForEach-Object {
    $rtn = Test-Connection -CN $_.dnshostname -Count 1 -BufferSize 16 -Quiet

    if($rtn -match 'True') {
        write-host -ForegroundColor green $_.dnshostname
    } 
    else {
        Write-host -ForegroundColor red $_.dnshostname
        "$_.dnshostname"| out-file -File 'c:\users\tony\desktop-Append
    } 
}

 

So far it works like it suppose to but I want to be 100 percent sure that the machine that are given to me on the text file are offline what is another command to verify that the machine is offline.


Viewing all articles
Browse latest Browse all 6937

Trending Articles