use Powershell to install an MSI located on a web site with a username pwd

I have an MSI located on a web site that is secured with a basic username/pwd.

I need to use powershell to install it on a local server.
What syntax do I need to use for that?

here is what I have tried:
A) msiexec /i "https://Mysite.myserver.com/Myinstall.msi"
B) start-process -filepath msiexec.exe -argumentlist "/i https://Mysite.myserver.com/Myinstall.msi"

Each time I run these it tells me it can't locate the MSI. I suspect it is because of the username/pwd on the web site.

Ideas?
JasonLattinAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Raheman M. AbdulConnect With a Mentor Senior Infrastructure Support Analyst & Systems DeveloperCommented:
Try this:

$source = "https://Mysite.myserver.com/Myinstall.msi"

$destination = "c:\temp\Myinstall.msi"

$userid="usernameHere"

$passwd="passwordHere"


$client = New-Object System.Net.Webclient

$client.Credentials = New-Object System.Net.NetworkCredential($userid,$passwd)

$client.DownloadFile($source, $destination)

# Wait until file downloaded.
Start-Sleep -Seconds 10  

while(!(Test-Path $destination)) {
  Start-Sleep -Seconds 10;
 }

msiexec /i $destination
0
 
JasonLattinAuthor Commented:
@Raheman
Your script works fine if the file is on a regular http site but it fails on an https site. My site is secured with a certificate, requiring https.

Ideas?
0
 
JasonLattinAuthor Commented:
@Raheman
Further testing shows that it isnt the certificate / https that is breaking the script. It seems to be my username/pwd on that site. If I open the site to not require a username/pwd then your script works like a charm.
Just need to figure out how to address the username/pwd issue for the site.
0
Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

 
Raheman M. AbdulSenior Infrastructure Support Analyst & Systems DeveloperCommented:
For that the page source is required then we can parse and use the login details to enter to the site. otherwise we can use sendkeys()
is that externall site or internal site?
0
 
JasonLattinAuthor Commented:
@Raheman
The MSI is on an external web site. it never prompts for login so i'm not sure how sendkeys() will work but i am sure you have other thoughts.
0
 
JasonLattinAuthor Commented:
This works like a charm. Does not work for HTTPS sites but for regular sites it works fine.
0
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.

All Courses

From novice to tech pro — start learning today.