Eldo issac
asked on
Exe file remote Execution using powershell
I'm trying to write a script which will patch SQL Instances remotely. Referring this forum, I have framed the following line for executing the .exe remotely on other server:
Also tried this as well:
Kindly help me on this.
Invoke-Command -ComputerName $computer -ScriptBlock {& cmd /c 'D:\SQL_PATCH\SQLServer2012SP2-KB2958429-x64-ENU.exe' /qs /action=patch /allinstances /IAcceptSQLServerLicenseTerms}
Also tried this as well:
Invoke-Command -ComputerName $computer -ScriptBlock {& 'D:\SQL_PATCH\SQLServer2012SP2-KB2958429-x64-ENU.exe' -ArgumentList "/qs", "/action=patch", "/allinstances", "/IAcceptSQLServerLicenseTerms"}
Kindly help me on this.
Are you getting any errors? Do you have the access rights to execute those commands on the remote server?
ASKER
Hello Bob,
There are no errors that I'm getting. But it's not installing everything. Also, on the remote server I have admin rights and powershell remoting has been enabled.
There are no errors that I'm getting. But it's not installing everything. Also, on the remote server I have admin rights and powershell remoting has been enabled.
"But it's not installing everything."
We must be clear here: is it installing anything? If so, what pieces are missing?
Is there a log file written?
Are all the SQL Servers the same version?
We must be clear here: is it installing anything? If so, what pieces are missing?
Is there a log file written?
Are all the SQL Servers the same version?
ASKER
Hello bob,
Apologies for the wrong comment. Actually it's not installing anything. The statement just executes in split second and nothing. There are no log files generated in setup bootstrap and the SQL version is not changing.
Apologies for the wrong comment. Actually it's not installing anything. The statement just executes in split second and nothing. There are no log files generated in setup bootstrap and the SQL version is not changing.
It would really help to have a log file here. It looks like the commands are executable Windows installer files. If so, then you can enable logging as described here:
How do I create an installation log?
http://www.advancedinstaller.com/user-guide/qa-log.html
How do I create an installation log?
http://www.advancedinstaller.com/user-guide/qa-log.html
ASKER
Hello Bob,
The command is for updating SQL to SP2. I looked at the link, didn't understand properly. Can you please suggest an edit in the above command for generating logs?
The command is for updating SQL to SP2. I looked at the link, didn't understand properly. Can you please suggest an edit in the above command for generating logs?
Run this as a test. Start a persistent session.
$s = New-PsSession -computername $computer
Run the remote command using the session.Invoke-Command -Session $s -ScriptBlock {& D:\SQL_PATCH\SQLServer2012SP2-KB2958429-x64-ENU.exe /qs /action=patch /allinstances /IAcceptSQLServerLicenseTerms}
Check back in a bit to see if the install completed.
I figured out what you are running now:
Installing Updates from the Command Prompt
https://msdn.microsoft.com/en-us/library/dd638066.aspx
Unfortunately, i don't see a logging argument in the list of supported arguments, so ignore the man behind the green curtain.
Installing Updates from the Command Prompt
https://msdn.microsoft.com/en-us/library/dd638066.aspx
Unfortunately, i don't see a logging argument in the list of supported arguments, so ignore the man behind the green curtain.
Overview of SQL Server Servicing Installation
https://technet.microsoft.com/en-us/library/dd638062(v=sql.110).aspx
https://technet.microsoft.com/en-us/library/dd638062(v=sql.110).aspx
By default, SQL Server 2012 update log files are saved to %Program Files%\Microsoft SQL Server\110\Setup Bootstrap\LOG\.
ASKER
@footech: I tried running your command. No installation is happening but log files are getting generated in setup bootstrap. This is the content of the file:
The same has been attached here.
@Bob: Still going by the original command, no logs are getting generated at the location u said.
Log.txt
Exception of type 'System.OutOfMemoryException' was thrown.
The same has been attached here.
@Bob: Still going by the original command, no logs are getting generated at the location u said.
Log.txt
Looking at a link Bob provided, I'd say you need to use the /quiet switch and not /qs.
ASKER
@footech: Still not the working.
You could try PsExec. I've encountered things that just won't install (like .Net Framework, think it was a restriction of WUSA.exe) via PS Remoting. If logging doesn't reveal anything further, I'm out of ideas.
ASKER
@footech: Can you please tell how can I do that. I have already used PSExec for installing msi on remote servers. Can you please tell how I can I do for exe installation.
This is the command I'm using for msi installation:
This is the command I'm using for msi installation:
psexec \\$computer -s -u Adminuser -p AdminPassword msiexec /i C:\Avamar\AvamarClient-windows-x86_64-7.0.102-47.msi /qb ADVANCED_OPTIONS=1 CHANNEL=100
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks a ton FOOTECH. That just worked fine. Can you please tell one more thing.
Since this script is for updating SQL servers remotely, can you please suggest if I can run the above script parallel on all the servers?
This is required since we have a lot of servers in our environment and we are in the process of automating it. Kindly give your comments in this matter.
Thanks again
Since this script is for updating SQL servers remotely, can you please suggest if I can run the above script parallel on all the servers?
This is required since we have a lot of servers in our environment and we are in the process of automating it. Kindly give your comments in this matter.
Thanks again
To run in parallel you would have to run multiple instances of PsExec. Think multiple command windows.
ASKER
No yaar. that wouldn't be possible. We have around 100+ servers. Running multiple instances is not a chance in this scenario.
That's the only way to do it in parallel. You can provide a list of servers to each instance. So you could have 5 (or however many) instances running at the same time, and each one would work on a group of servers in a serial fashion. Limitations of the tool. Perhaps you could write a batch file (or other script) that would open the command windows and run PsExec in each one.