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:

Invoke-Command -ComputerName $computer -ScriptBlock {& cmd /c 'D:\SQL_PATCH\SQLServer2012SP2-KB2958429-x64-ENU.exe'  /qs /action=patch /allinstances /IAcceptSQLServerLicenseTerms}

Open in new window


Also tried this as well:

Invoke-Command -ComputerName $computer -ScriptBlock {& 'D:\SQL_PATCH\SQLServer2012SP2-KB2958429-x64-ENU.exe' -ArgumentList "/qs", "/action=patch", "/allinstances", "/IAcceptSQLServerLicenseTerms"}

Open in new window


Kindly help me on this.
Eldo issacAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bob LearnedCommented:
Are you getting any errors?  Do you have the access rights to execute those commands on the remote server?
0
Eldo issacAuthor Commented:
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.
0
Bob LearnedCommented:
"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?
0
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Eldo issacAuthor Commented:
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.
0
Bob LearnedCommented:
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
0
Eldo issacAuthor Commented:
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?
0
footechCommented:
Run this as a test.  Start a persistent session.
$s =  New-PsSession -computername $computer

Open in new window

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}

Open in new window

Check back in a bit to see if the install completed.
0
Bob LearnedCommented:
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.
0
Bob LearnedCommented:
Overview of SQL Server Servicing Installation
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\.
0
Eldo issacAuthor Commented:
@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:

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
0
footechCommented:
Looking at a link Bob provided, I'd say you need to use the /quiet switch and not /qs.
0
Eldo issacAuthor Commented:
@footech: Still not the working.
0
footechCommented:
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.
0
Eldo issacAuthor Commented:
@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:

    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

Open in new window

0
footechCommented:
Should be the same as you would use to do a silent install on a local machine.  Maybe
psexec \\computer -s -u Adminuser -p AdminPassword D:\SQL_PATCH\SQLServer2012SP2-KB2958429-x64-ENU.exe /quiet /action=patch /allinstances /IAcceptSQLServerLicenseTerms

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Eldo issacAuthor Commented:
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
0
footechCommented:
To run in parallel you would have to run multiple instances of PsExec.  Think multiple command windows.
0
Eldo issacAuthor Commented:
No yaar. that wouldn't be possible. We have around 100+ servers. Running multiple instances is not a chance in this scenario.
0
footechCommented:
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.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.