Powershell Test connection then mstsc

Kelly Garcia
Kelly Garcia used Ask the Experts™
on
Hi All,

I have this line of code that test connection for servers:

PS G:\> Test-Connection -ComputerName  sdindc01, sraddc01, sdendc01, senadc01, sewcdc01, solidc01 -Count 1 | selec
t address

Open in new window


if the ping is successful I then want to Mstsc in to the servers, I've tried:
$t=Test-Connection -ComputerName  sdindc01, sraddc01, sdendc01, senadc01, sewcdc01, solidc01 -Count 1 | selec
t address
$t | % {mstsc /v:$_}

Open in new window


However this does not work. please help
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Senior Network Consultant / Engineer
Commented:
Try this:
$t=Test-Connection -ComputerName  sdindc01, sraddc01, sdendc01, senadc01, sewcdc01, solidc01 -Count 1 | select -ExpandProperty address
$t | % {mstsc /v:$_}

Open in new window

Jeremy WeisingerSenior Network Consultant / Engineer

Commented:
Glad to help. :)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial