Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am new to Amazon servers. I recently created an EC2 Windows2008 R2 instance and tried to connect to the instance from my system using powershell ALONE

I don't want to use Amazon API in connecting, transferring a file from local to EC2, or installing the files in the EC2 instance.

I want to accomplish all these just by using POWERSHELL.

I am able to connect and transfer files from local to EC2, Can some one suggest/ help to install the executable files on this EC2 instance.

Any help in this matter is deeply appreciated! thx in advance

share|improve this question
add comment

3 Answers

If you can install your executable from the command line ('silent install') then powershell remoting is the best choice. It is on by default on the Amazon Windows images, so you don't need to do anything other then start up the machine and grab the password.

There are instructions for setting up remoting here: http://stackoverflow.com/a/13284313/1335661

The bottom line is that you can use the following script to execute a remote command (taken from: https://github.com/CloudifySource/cloudify/blob/master/esc/src/main/resources/clouds/ec2-win/upload/bootstrap-client.ps1):

param ([string]$target, [string]$username, [string]$password, [string]$command)

$ErrorActionPreference="Stop"

# Set up the password
$securePassword = ConvertTo-SecureString -AsPlainText -Force $password
$cred = New-Object System.Management.Automation.PSCredential $username, $securePassword

Write-Host "Connecting to management service of $target"
Connect-WSMan -Credential $cred $target 

set-item WSMan:\$target\Client\TrustedHosts -Value * -Force
set-item WSMan:\$target\Shell\MaxMemoryPerShellMB -Value 0 -Force

Write-Host Invoking command on Remote host $target
Invoke-Command -ComputerName $target -Credential $cred  -ScriptBlock {  
    Invoke-Expression $args[0]
} -ArgumentList $command
Write-Host "Command finished"

You can run this command from your own script with the following command:

powershell.exe -inputformat none -File PATH_TO_SCRIPT -target TARGET_IP -password PASSWORD -username USERNAME -command COMMAND_TO_EXECUTE
share|improve this answer
add comment

Unless you are savvy in PowerShell Remoting, I recommend just opening up RDP (TCP 3389) and Remote Desktoping in (check the client box for connecting local drives) and upload files that way. Then later you can experiment with the PowerShell command Enable-PSRemoting on the server, opening the firewall for 5986 (SSL) and trying to get in remotely.

Not sure you can "tunnel" file transfers through a PowerShell remote shell natively, although there seems to be a 3rd party module for that.

share|improve this answer
add comment

I assume you are talking about installing software on the server without having to log in.

One option is to install https://github.com/bwight/CloudInit.NET on your server and save an AMI. Then you can write a powershell script that will run on the server locally and install / download whatever you need to the server.

When you create the new server using this AMI just put the contents of the file as the user-data or user-data-file. When the server boots up the CloudInit.NET service will download and execute your script without you having to log into the server.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.