Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

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.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

How to install an application using PowerShell

Closed Thread
 
Thread Tools Display Modes
Old 01-10-2008   #1 (permalink)
Michael
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
Old 01-10-2008   #2 (permalink)
Shay Levi
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


Quote:

> 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

Old 01-10-2008   #3 (permalink)
Michael
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:
Quote:

>
> 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
>
>
>
Quote:

> > 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
>
>
>
Old 01-10-2008   #4 (permalink)
Shay Levi
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


Quote:

> 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:
>
Quote:

>> 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
Quote:

>>> 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

Old 01-14-2008   #5 (permalink)
Michael
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:
Quote:

> 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:
>
Quote:

> >
> > 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
> >
> >
> >
Quote:

> > > 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
> >
> >
> >
Old 01-14-2008   #6 (permalink)
Shay Levi
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
Quote:

> 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:
>
Quote:

>> 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:
>>
Quote:

>>> 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
>>>> 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

Closed Thread

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








Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50