3

My boss is on vacation and I'm supposed to have this installation script done by the time he returns. Unfortunately, I've realized that the script I developed won't work on the target server setup and I don't know enough about it to know how to figure it out.

The server is running SQL Server 2008 R2 standard SP1, and my installation script is PowerShell v1 and requires access to two snapins on the database server and one snapin on the webserver.

He has the webserver separated from the dataserver in such a way that the dataserver is accessible only via RDP from the webserver desktop. The script I developed on my setup works fine, but that is because my webserver and dataserver are not separated. On his setup, I can run the DB part of the installation on the dataserver successfully, and the website part on the webserver successfully, but he expects that I will have a single script for the installation.

I can't figure out how to get the two instances to talk to each other to make this happen. Is it possible to make this work as a single script? I don't even know how to start.

Kit Z. Fox
  • 133
  • 1
  • 5
  • My gut instinct is to say "Run the DB Server portion of the script with [`psexec`](http://technet.microsoft.com/en-us/sysinternals/bb897553.aspx) or similar", but depending on how the servers are separated (firewall settings, etc.) that may not be viable... – voretaq7 Jan 15 '13 at 19:47
  • Start by defining exactly what access you have to the DB server from the web server, from the web server to the database server, and both from a third machine. I am guessing your DB, and web server are in different firewall zones or something? What you are trying to do, simply may not be possible because of how your network is setup. – Zoredache Jan 15 '13 at 20:10
  • @Zoredache I have RDP access. I don't appear to be able to access the dataserver via any other method, although I can ftp to the webserver from my dev box, and we have a shared drive. It looks like the dataserver might be connected like a LAN, but I show no computers in the network. My boss is the one who set it up, so I don't have many details. Server configuration is not my strong point. I may just have to wait until he returns, so I can get enough information to ask a clearer question. – Kit Z. Fox Jan 15 '13 at 20:38
  • Well anyway, I suggest you build your script in a way that it is two-parts, but both parts can easily be initiated from external third system assuming your boss will adjust the network to permit ps-remoting, or psexec or something. – Zoredache Jan 15 '13 at 20:43

2 Answers2

3

There are tons of options here. Any google search for "remote installation", "remote powershell", "remote exec" and so on will help you.

Since the entire thing is in PowerShell then you should probably use WinRM: http://technet.microsoft.com/en-us/magazine/ff700227.aspx

The Windows PowerShell remoting features are supported by the WS-Management protocol and the Windows Remote Management (WinRM) service that implements WS-Management in Windows. Computers running Windows 7 and later include WinRM 2.0 or later. On computers running earlier versions of Windows, you need to install WinRM 2.0 or later as appropriate and if supported. Currently, remoting is supported on Windows Vista with Service Pack 1 or later, Windows 7, Windows Server 2008, and Windows Server 2008 Release 2.

pauska
  • 19,620
  • 5
  • 57
  • 75
2

Configure PowerShell remote sessions on the relevant servers:

Enable-PSRemoting

Your script can then connect to them:

$s = New-PSSession server.domain.local
Import-PSSession $s
... continue script, remote cmdlets will now be available ...

If you want an interactive "shell" experience just run

Enter-PSSession server.domain.local

Depending on what you want to do there's probably other options, arguments, and commands you'll want to call; but this should at least give you a strong shove in the right direction.

Chris S
  • 77,945
  • 11
  • 124
  • 216