Import-Module activedirectory $XDMachines = Get-ADComputer -LDAPFilter “(name=*)”-SearchBase “OU=XenDesktop-VMs,OU=WorkStations,DC=mulpuru,DC=local” foreach ($XDMachine in $XDMachines) { if(Test-Connection -ComputerName $XDMachine.Name -Quiet -Count 1) { Invoke-Command -ComputerName $XDMachine.Name -ScriptBlock { ipconfig /renew} } }
Tag Archives: test-connection
Ping that returns a Boolean
PS C:\Users\SivaMulpuru> Test-Connection google.com -Quiet -Count 1 True PS C:\Users\SivaMulpuru> Test-Connection google.local -Quiet -Count 1 False Good practice to check for the host’s state before making a connection. Reference http://technet.microsoft.com/en-us/library/dd315259.aspx