PowerShell Remote installation of MSI installation package, EXE executable program method _powershell

Source: Internet
Author: User

Although this is a common task for IT administrators or developers, there are relatively few documents available on the web to find "Remote installation of an MSI package or EXE application." Even in the comments of some forums, it was not possible to achieve this. Actually, it's OK. I will provide two pieces of code in this article, responsible for the remote installation of the MSI package and EXE executable application.

First, install the MSI package

Using PowerShell to invoke the WMI object, you can execute the following script to install your MSI installation package:

Copy Code code as follows:
$box = "Deviis01" #this is the name of your server
$product = [WMIClass] "\ $box \root\cimv2:win32_product"
Write-host "Installing software on $box"
$product. Install ("C:\Setup \somesoftwarepackage.msi")

It can be installed silently, so it's no longer a concern to use command parameters.

Note: Some installation packages may require the user to select or set many options during the installation process.

Second, the installation of EXE application

Egg pain is the use of the above method can not successfully install EXE executable installation package, if there are children's shoes have Haiten, can message share under the idea or code, because I am also curious whether this is feasible. However, we can use another method to install the EXE.

Copy Code code as follows:
Write-host "Installing software on $box"
([WMIClass] "\ $box \root\cimv2:win32_process"). Create (
"Cmd.exe/c c:\setup\somesoftware.exe/s/V" "/qn")

The above script actually creates a new process on the remote machine, calls Cmd.exe, passes the executable package as a parameter, and then passes the parameters that the installer needs. This involves a lot of string escape, with the quotation mark conversion, you should be extra careful.

Article Source: http://www.pstips.net/install-application-remotely.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.