Solved

How to connect to  different servers and run local scripts?

Posted on 2011-02-25
3
992 Views
Last Modified: 2012-05-11
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

0
Comment
Question by:missymadi
  • 2
3 Comments
 
LVL 10

Accepted Solution

by:
lanboyo earned 500 total points
ID: 34985095
I have not verified this but...

http://huddledmasses.org/scriptable-ssh-from-powershell/

using the ssh-keygen app from putty you can also enable the servers for passwordless login...
0
 

Author Comment

by:missymadi
ID: 34991947
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
0
 

Author Closing Comment

by:missymadi
ID: 35235755
Did not respond
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Create and license users in Office 365 in bulk based on a CSV file. A step-by-step guide with PowerShell script examples.
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
Viewers will learn how to properly install and use Secure Shell (SSH) to work on projects or homework remotely. Download Secure Shell: Follow basic installation instructions: Open Secure Shell and use "Quick Connect" to enter credentials includi…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question