In the last weeks i have spent a lot of time coding Powershell scripts. In the next few days i will share some of them because i think they have added value to the Powershell community.
This script will test AD computers (one or a whole range) on connectivity and return its state in green (when the machine is up) or red (when the machine is down) its core provider is the Active Directory module of powershell and the Test-Connection cmdlet that basicly tests a connection with a ping.
# This script tests the connectivity of Active Directory computers
# Script built by Bas Huygen februari 2013
# The usefull variable ErrorActionPreference is used to control the feedback Powershell returns to the ‘default-out’ $ErrorActionPreference = "SilentlyContinue"
# we’re clearly using the AD module here…
Import-Module ActiveDirectory
Clear-Host
$inp = Read-Host "give the name of the machine that has to be checked `n
It is also possible to use a wildcard (*) to test a range of computers`n
For example giving SER* will test all AD computers starting with a name like SER01 or SERvertest `n
not providing a value here will input * which means all AD computers will be scanned"
If($inp -eq ""){$inp = "*"} $ir = 0; $is = 0
foreach($comp in (Get-ADComputer -filter * |where {$_.Name -like $inp})){`
If(Test-Connection -Count 1 $comp.name){$ir ++ ;Write-Host "Machine " $comp.name "is up-and-running" -ForegroundColor Green}`
Else{$is ++;Write-Host "Machine " $comp.name "is down" -ForegroundColor Red}}
Write-Host "---------------------`n"
Write-Host "total running machines is" $ir -ForegroundColor Green
Write-Host "total stopped machines " $is -ForegroundColor Red
output looks like this:
have fun with it and questions, please leave them at this page and i will get back to you.
Labels
Powershell
(18)
MDT
(9)
Active Directory
(7)
MDT 2012
(5)
Microsoft Deployment Toolkit
(5)
PSexec
(5)
Primal Forms
(4)
Wake on LAN
(4)
Zerotouch deployment without SCCM
(4)
MDT Database Object Property
(3)
MDTDB powershell module
(3)
MDX
(3)
Michael Niehaus MDTDB module
(3)
PXE
(3)
MDT Property values
(2)
PowerShell array
(2)
Start LiteTouch deployment remote
(2)
System Center Config Manager 2012
(2)
Use PowerShell to start MDTdeployment remote
(2)
WOL
(2)
Cluster network name resource 'Cluster Name' failed registration of one or more associated DNS name(s) for the following reason
(1)
EventID 1196
(1)
Hyper-V 2012
(1)
Microsoft-Windows-Failover-clustering
(1)
W32Time
(1)
Windows time
(1)
custom drive configuration in MDT
(1)
failover cluster
(1)
time synchronization in AD
(1)
understanding MDT deployments. LiteTouch deplyment
(1)
use PowerShell to wake up machine
(1)
No comments:
Post a Comment