logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
Will H  
#1 Posted : Tuesday, June 6, 2017 7:41:41 PM(UTC)
Will H


Rank: Administration

Joined: 11/23/2016(UTC)
Posts: 4
United States

Thanks: 6 times
Was thanked: 3 time(s) in 1 post(s)
There are a few posts here about using the command pane to do interesting things, but I didn't see anything that covered this use scenario:

If you have a bunch of Windows access agents and you'd like to silently pull a file down to and then install it, you can use the command pane with a combination of commands to get this done. If you use the checkbox to multi-select a bunch of agents, you can run this on many/all agents simultaneously.

This example downloads a file from Dropbox, puts it in C:\temp, and then runs a silent MSIEXEC install with logging to the C:\temp directory. The pathnames and URLs would be changed for whatever your purposes are.

If your remote endpoint has POWERSHELL 3, populate the command pane like this:

Quote:
#!ps
#maxlength=50000
#timeout=300000
Invoke-WebRequest -Uri https://www.dropbox.com/link/ClientSetup.msi?dl=1 -OutFile C:\temp\ClientSetup.msi
#!cmd
msiexec /i C:\temp\ClientSetup.msi /qn /l*v C:\temp\installfail.log


If your remote endpoint has POWERSHELL 2, populate the command pane like this:

Quote:
#!ps
#maxlength=50000
#timeout=300000
(new-object System.Net.WebClient).DownloadFile('https://www.dropbox.com/link/ClientSetup.msi?dl=1','C:\temp\ClientSetup.msi')
#!cmd
msiexec /i C:\temp\ClientSetup.msi /qn /l*v C:\temp\installfail.log



If you run into a 1603 error on install, it means the software is probably already installed, or that the SYSTEM account doesn't have Full Access to the install location.

JAN 2018 EDIT: Since the posting of this, it seems the command pane has changed a bit and can't swap between PS and CMD on the fly.

The new process would involve splitting this in half, as seen here (with the PowerShell 3 example):

Quote:
#!ps
#maxlength=50000
#timeout=300000
Invoke-WebRequest -Uri https://www.dropbox.com/link/ClientSetup.msi?dl=1 -OutFile C:\temp\ClientSetup.msi


After that runs, switch from PS to CMD and run the installer silently.

Quote:
#!cmd
#maxlength=50000
#timeout=300000
msiexec /i C:\temp\ClientSetup.msi /qn /l*v C:\temp\installfail.log


Also, keep in mind that when linking to a file on Dropbox, changing the final part of the URL from dl=0 to dl=1 will skip the landing page and give a direct link to the file (which is necessary for this to work).

Edited by user Tuesday, January 2, 2018 10:35:53 PM(UTC)  | Reason: Clarifications

thanks 3 users thanked Will H for this useful post.
Michael L on 6/6/2017(UTC), Kkex on 2/8/2018(UTC), welz on 7/31/2018(UTC)
Kkex  
#2 Posted : Thursday, February 8, 2018 6:36:34 PM(UTC)
Kkex


Rank: Guest

Joined: 4/5/2017(UTC)
Posts: 3
Location: Las Vegas

Thanks: 1 times
Hi Will,

I believe you helped me with this about 8 months ago and that may be what prompted you to write this post after we worked on it back then. First off, many thanks to you as you've saved me a ton of time and energy being able to download files onto remote machines and install things silently (90% of our organization is remote). I've been using your method for quite awhile now with great success.

Today I'm hoping you can assist with taking this process a couple steps further. I need to install an msi that references a transformer file as an administrator (while still doing it all quietly). I know UAC and privileges can get in the way of this but I've seen that a Powershell script executed with "@powershell -NoProfile -ExecutionPolicy Bypass C:\temp\install.ps1" in the command pane should work. I've been toying with this method for some time but to no avail.

If you can help out at all with this it would be greatly appreciated. Thanks again for all your help!

Thanks,
Kyle
Will H  
#3 Posted : Thursday, February 8, 2018 8:12:39 PM(UTC)
Will H


Rank: Administration

Joined: 11/23/2016(UTC)
Posts: 4
United States

Thanks: 6 times
Was thanked: 3 time(s) in 1 post(s)
Kyle,

Glad to hear that the instructions above have been working for you well! You indeed were the reason I wrote this article in the first place!

Here's my advice on using a transform file with your MSI installer.

First, use a second Invoke-WebRequest command to pull the MST file down into the temp directory with the MSI file.

Next, issue the MSIEXEC command like this to include the transformer file:
msiexec /i C:\temp\nameofinstaller.msi /qn /l*v C:\temp\installfail.log TRANSFORMS=c:\temp\nameoftransformer.mst

I expect this would work for your situation unless there's some variable I haven't taken into consideration. I'm curious to know the results!

Best regards,
Will
ebell  
#4 Posted : Friday, February 9, 2018 2:17:56 AM(UTC)
ebell


Rank: Member

Medals: Level 1: Random Act of Kindness! Received One Thanks!

Joined: 5/13/2014(UTC)
Posts: 27
United States
Location: Texas

Thanks: 28 times
Was thanked: 5 time(s) in 3 post(s)
Thank Will for sharing this information with the community.

For those using the msi file only and not a transform file, you can simply use the /i switch to download and install the msi file from a remote location in a one-liner:

Code:

#!cmd
#maxlength=50000 
#timeout=300000 
msiexec /i http://www.domain.com/msp/ClientSetup.msi /qn


For those experiencing issues with downloading via PowerShell, you can use bitsadmin:

Code:

#!ps
#maxlength=10000
#timeout=90000
bitsadmin  /transfer FileDownload /download  /priority normal   http://www.domaincom/msp/file/filename.ext  C:\Support\filename.ext


Please note that in ALL of these scenarios you can adjust the #timeout= value to allow for extra time if you receive a timeout before the file is downloaded.
shawnkhall  
#5 Posted : Friday, February 9, 2018 11:02:29 PM(UTC)
shawnkhall


Rank: Advanced Member

Medals: Level 1: Random Act of Kindness! Received One Thanks!

Joined: 2/6/2014(UTC)
Posts: 295
Man
United States

Thanks: 7 times
Was thanked: 25 time(s) in 22 post(s)
BITS, while effective for some situations, will not behave well with any URL that uses a 302 redirect. :(
Kkex  
#6 Posted : Wednesday, February 14, 2018 4:53:12 PM(UTC)
Kkex


Rank: Guest

Joined: 4/5/2017(UTC)
Posts: 3
Location: Las Vegas

Thanks: 1 times
Originally Posted by: Will H Go to Quoted Post
Kyle,

Glad to hear that the instructions above have been working for you well! You indeed were the reason I wrote this article in the first place!

Here's my advice on using a transform file with your MSI installer.

First, use a second Invoke-WebRequest command to pull the MST file down into the temp directory with the MSI file.

Next, issue the MSIEXEC command like this to include the transformer file:
msiexec /i C:\temp\nameofinstaller.msi /qn /l*v C:\temp\installfail.log TRANSFORMS=c:\temp\nameoftransformer.mst

I expect this would work for your situation unless there's some variable I haven't taken into consideration. I'm curious to know the results!

Best regards,
Will


Hey Will,

The files are getting downloaded onto the machine correctly but I get an error in the command pane: "This installation package could not be opened. Contact the application vendor to verify that this is a valid Windows Installer package."

I spoke with the vendor and they gave me a BAT file to run that will do the install, the problem is it needs to be run as an administrator. Do you know how to do that? I tried making a shortcut and setting that to run as an administrator but no dice still. I'm guessing a powershell script will need to be run to do it.

Thanks,
Kyle
Will H  
#7 Posted : Wednesday, February 14, 2018 7:36:47 PM(UTC)
Will H


Rank: Administration

Joined: 11/23/2016(UTC)
Posts: 4
United States

Thanks: 6 times
Was thanked: 3 time(s) in 1 post(s)
Hey Kyle,

This portion of the msiexec command tells it to write a log during installation:

/L*V C:\temp\installfail.log

This sounds like an issue with the MSI itself. Can you paste the contents of that logfile here? It may shed some light on what's going on. You may want to run an MD5/SHA256 checksum against the MSI that you know is good vs the MSI that you're downloading to those remote machines, to make sure the downloaded one is not getting corrupted somewhere along the way.
shawnkhall  
#8 Posted : Thursday, February 15, 2018 5:25:07 PM(UTC)
shawnkhall


Rank: Advanced Member

Medals: Level 1: Random Act of Kindness! Received One Thanks!

Joined: 2/6/2014(UTC)
Posts: 295
Man
United States

Thanks: 7 times
Was thanked: 25 time(s) in 22 post(s)
every command run thru the commands feature is run elevated (as admin). it is NOT run in the user context, though, and some applications (like dropbox) require running in the user context as well. runas can get around this problem.
point99trash2011  
#9 Posted : Tuesday, February 20, 2018 2:39:07 AM(UTC)
point99trash2011


Rank: Member

Medals: Level 1: Random Act of Kindness! Received One Thanks!

Joined: 7/28/2014(UTC)
Posts: 14
United States
Location: NM

Thanks: 4 times
Was thanked: 4 time(s) in 3 post(s)
Originally Posted by: Will H Go to Quoted Post

JAN 2018 EDIT: Since the posting of this, it seems the command pane has changed a bit and can't swap between PS and CMD on the fly.

The new process would involve splitting this in half, as seen here (with the PowerShell 3 example):

Quote:
#!ps
#maxlength=50000
#timeout=300000
Invoke-WebRequest -Uri https://www.dropbox.com/link/ClientSetup.msi?dl=1 -OutFile C:\temp\ClientSetup.msi


After that runs, switch from PS to CMD and run the installer silently.

Quote:
#!cmd
#maxlength=50000
#timeout=300000
msiexec /i C:\temp\ClientSetup.msi /qn /l*v C:\temp\installfail.log



You could run the command as follows via powershell's own interface so you don't need to run 2 halves of it one powershell, the other cmd.

Quote:
& "$Env:temp\installer.exe" -arguments here


so your example becomes

Quote:
& "$Env:windir\system32\msiexec.exe" /i C:\temp\ClientSetup.msi /qn /l*v C:\temp\installfail.log


However as you can tell by my example I am partial to using $Env:temp which translates to c:\windows\temp usually, or wherever the windows temp folder is.

I use this to remotely run a speedtest on computers without impacting it by my remote presence on it

Quote:
#!ps
#maxlength=50000
#timeout=90000
(New-Object System.Net.WebClient).DownloadFile("https://github.com/zpeters/speedtest/releases/download/speed-issues/speedtest-32-speed-issues.exe","$Env:temp\speedtest.exe")
& "$Env:temp\speedtest.exe" -r
thanks 2 users thanked point99trash2011 for this useful post.
Will H on 2/20/2018(UTC), rich2323 on 4/3/2018(UTC)
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.