Link to home
Start Free TrialLog in
Avatar of missymadi
missymadi

asked on

How to connect to different servers and run local scripts?

Experts,

       I need to create a Powershell script that will go out and SSH from the PDC. The SSH needs to reach WIndows machines, thin clients, VSM, RHEL5. Once the connection is made I need a local script run. I wrote a psuedocode of what I'm looking for..
I have putty on Windows server. So I can take advantage of plink etc.
Thanks, Missymadi
# If servers are Windows

If $Computer = “Windows” do the following

$ArrComputers = "Computer1", "Computer2", "Computer3" 
foreach ($Computer in $ArrComputers) 
{ write-host "
" write-host "====================================" 
write-host 
"Computer: $Computer" 
write-host "====================================" write-host "-----------------------------------"
 write-host "Win32_PnPEntity instance"
 write-host "-----------------------------------" 

Run a Windows Powershell script
Exit
} 

#If servers are RHEL5 Servers

If $Computer = “RHEL5” do the following

plink root@Linuxbox -m local_script.sh

#if servers are VM host 

Connect-viserver –server <server> -user <user> -password<pwd>
(use the Connect-VIServer cmdlet and provide a value to the server parameter

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of lanboyo
lanboyo

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of missymadi
missymadi

ASKER

I want to try this in our lab. Do I need the latest copy of Powershell for this to work?

Do you have an example of a Powershell script that would connect from a Win2k3 to a Linux machine and run a script?

I'm also looking for guidance for creating a Powershell script like I discribed above. I need one script and based on the computer name, and if it is pingable then connect to the remote computer and run a local script.
Thanks, Missymadi
Did not respond