![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | How to install an application using PowerShell I was not able to find anything on this on the Internet, which surprised me since I would have figured it would be a common task, but anyways, I need to create a PowerShell script that will install a EXE or MSI on a given server. I will provide the path of the install and the destination server but I am not sure how to do it in PowerShell. Any ideas? Thanks! Michael |
| | #2 (permalink) | ||||||||||||
| Guest | Re: How to install an application using PowerShell First find out what switches you can use on the exe or msi file. Check for silent switches. For instanace, MSI files can be installed (and automated with MST files) with no user interaction, Quiet mode. For a complete list type: msiexec /?. It'll give you a start. Do the same on the setup file and check the vendor documentation too. To execute the files use the call operator, check also the invoke-expression,invoke-item cmdlets. & setupFile "Arg1" "Arg2" "Arg3" If you run it inside a script, you can find out if the operation succeeded by quering PowerShell automatic variable $LASTEXITCODE, genarally, a value of 0 means success. Remember to pie your command to out-null to prevent powershell from proceeding to next line of code and waiting for the command to end. & setupFile "Arg1" "Arg2" "Arg3" | out-null if($LASTEXITCODE -eq 0) { "success" } ----- Shay Levi $cript Fanatic http://scriptolog.blogspot.com Hebrew weblog: http://blogs.microsoft.co.il/blogs/scriptfanatic
| ||||||||||||
| | #3 (permalink) | ||||||||||||||||||||||||
| Guest | Re: How to install an application using PowerShell Hi Shay, Thanks for the help! I do appreciate it! One last question, how do I get this to install on a server? Say I run the PS1 script on my local computer, is there a way to have it execute the install on ServerA? Thanks, Michael "Shay Levi" wrote:
| ||||||||||||||||||||||||
| | #4 (permalink) | ||||||||||||||||||||||||||||||||||||
| Guest | Re: How to install an application using PowerShell You can copy the file to that server, to a known path and then use WMI to create a new process on the remote computer with the command line switches. I'm not sure you'll get a safe value for the $LASTEXITCODE as WMI returns the new process id, and the return value is of the WMI call (not the installation process exit code). It will also be a pain to wait for that process to end. PowerShell v2 remoting will contribute alot to resolve such problems. ----- Shay Levi $cript Fanatic http://scriptolog.blogspot.com Hebrew weblog: http://blogs.microsoft.co.il/blogs/scriptfanatic
| ||||||||||||||||||||||||||||||||||||
| | #5 (permalink) | ||||||||||||||||||||||||||||||||||||
| Guest | Re: How to install an application using PowerShell I finally solved my problem. Below is how you can install an application on a remote machine using PowerShell and WMI-Objects. $product= [WMICLASS]"\\$box\ROOT\CIMV2:win32_Product" $product.Install("c:\thepathtoyourprogram.msi") Now, $box is the name of your server and also another thing I noticed, this works best with MSI files; if you get into exe's it could work depending on what installer you used to build your exe. Since my company uses InstallShield, this wouldnt work because for whatever reason InstallShield did not like the parameters I tried to pass, so I had to do something different with a exe which is below. ([WMICLASS]"\\$box\ROOT\CIMV2:win32_process").Create("cmd.exe /c c:\pathtoyourexehere.exe /s /v`" /qn") So, there are two examples of installing applications on a remote system, either with an MSI or an EXE. "Michael" wrote:
| ||||||||||||||||||||||||||||||||||||
| | #6 (permalink) | ||||||||||||||||||||||||||||||||||||
| Guest | Re: How to install an application using PowerShell Glad you could resolve it. Thanks for posting your solution. ----- Shay Levi $cript Fanatic http://scriptolog.blogspot.com
| ||||||||||||||||||||||||||||||||||||
| |
| |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| PowerShell installation for application deploymet for Exchange2k7 | Cyber Friend | PowerShell | 1 | 11-26-2007 06:57 AM |
| remote application pool recycle using WMI \ PowerShell | Bill | PowerShell | 20 | 11-10-2007 09:53 AM |
| Uninstall an application using Powershell | y.bobzhang | PowerShell | 1 | 10-05-2007 08:36 PM |
| Creating an IIS7 application with PowerShell | Joe Brinkman | PowerShell | 5 | 10-03-2007 07:02 AM |
| Using Powershell to script existing application, HomeSite | Mike Gale | PowerShell | 2 | 06-01-2007 06:57 PM |