Avatar of PennCharter
PennCharter

asked on 

How to remotely install software using Powershell

I was wondering how to remotely install software using powershell.

I can connect to other computers using the WMI win32_products to uninstall current software, but I don't know how to install new software.
Scripting LanguagesPowershellWindows Networking

Avatar of undefined
Last Comment
BSonPosh
Avatar of BSonPosh
BSonPosh
Flag of United States of America image

Try this

$machine = "Server Name"
$MSIFile = "c:\your.msi"
$product = [WMICLASS]"\\$machine\ROOT\CIMV2:win32_Product"
$product.Install($MSIFile,$null,$true)

Open in new window

Avatar of PennCharter
PennCharter

ASKER

I need to pass a -Credential or I get an Access Denined error.

Is there a way to pass a -Credential on a [WMICLASS]"\\$machine\ROOT\CIMV2:win32_Product"?
Avatar of BSonPosh
BSonPosh
Flag of United States of America image

nope... sorry :(
Avatar of PennCharter
PennCharter

ASKER

I was able to connect using this script. When I try $pc.Install($install), I get this message:


__GENUS          : 2
__CLASS          : __PARAMETERS
__SUPERCLASS     :
__DYNASTY        : __PARAMETERS
__RELPATH        :
__PROPERTY_COUNT : 1
__DERIVATION     : {}
__SERVER         :
__NAMESPACE      :
__PATH           :
ReturnValue      : 3

The software does not install on remote computer.
$pc = gwmi -query "SELECT * FROM Meta_Class WHERE __Class = 'win32_product'" -namespace "root\cimv2" -computername "USLAB01" -Credential $mycred

Open in new window

Avatar of BSonPosh
BSonPosh
Flag of United States of America image

Get-WMIObject -ne [WMICLass]

Take a look at http://blogs.msdn.com/powershell/archive/2006/06/26/647038.aspx perhaps that will explain it a little better.
Avatar of PennCharter
PennCharter

ASKER

Really?

$pc = gwmi -query "SELECT * FROM Meta_Class WHERE __Class = 'win32_product'" -namespace "root\cimv2" -computername "USLAB01" -Credential $mycred

$pc | gm

TypeName: System.Management.ManagementClass#ROOT\cimv2\Win32_Product
Name                MemberType
----                ----------
Name                AliasProperty
Admin               Method
Advertise           Method
Install             Method
__CLASS             Property
__DERIVATION        Property
__DYNASTY           Property
__GENUS             Property
__NAMESPACE         Property
__PATH              Property
__PROPERTY_COUNT    Property
__RELPATH           Property
__SERVER            Property
__SUPERCLASS        Property
ConvertFromDateTime ScriptMethod
ConvertToDateTime   ScriptMethod
Avatar of BSonPosh
BSonPosh
Flag of United States of America image

I think Richard does a good job of covering this on his blog
http://richardsiddaway.spaces.live.com/blog/cns!43CFA46A74CF3E96!1525.entry
Avatar of PennCharter
PennCharter

ASKER

Thank you, the Blog was helpfull. I still don't quite understand. When I do this:

$pc = [WmiClass]"\\uslab01\ROOT\CIMV2:win32_Process"
$pc.Create("Notepad.exe")

When I look on the computer uslab01, I see a notepad.exe process created, but the program doesn't start.
Avatar of BSonPosh
BSonPosh
Flag of United States of America image

It does start... just not interactively.
Avatar of PennCharter
PennCharter

ASKER

I just don't see the point of [WmiClass] yet. When I try $pc.Install($install_path), I see the process running on the remote pc's task manager, but nothing ever gets install.

Thanks for your help.
ASKER CERTIFIED SOLUTION
Avatar of BSonPosh
BSonPosh
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Windows Networking
Windows Networking

The Windows operating systems have distinct methodologies for designing and implementing networks, and have specific systems to accomplish various networking processes, such as Exchange for email, Sharepoint for shared files and programs, and IIS for delivery of web pages. Microsoft also produces server technologies for networked database use, security and virtualization.

51K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo