Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Having trouble with a function that pushes an MSI installer using WMI

$
0
0

I've come up with the following code block, but it doesn't seem to want to run on any of the machines I have here:

function Push-WMIfile
 {
    param ( 
    [Parameter(mandatory=$true)]
    [string[]]$path,        # path of file to push - example: \\server\share\software\McAfee\MFEagent.msi
    [string[]]$parameters,  # parameters you want to pass to the installer - example: "-install" or "/qn"
    [string[]]$compname)    # Name of the computer you'd like to push the package to - example "10.0.0.101" or "biz0027"


$packageinstall=(split-path $path -leaf) + ' ' + $parameters # evaluates to: MFEagent.msi -install
copy-item $path "\\$compname\c$\temp" # copy install file to the remote machine
$newProc=([WMICLASS]"\\$compname\root\cimv2:win32_Process").Create("C:\temp\$packageinstall")
If ($newProc.ReturnValue -eq 0) { Write-Host $_ $newProc.ProcessId } else { write-host $_ Process create failed with $newProc.ReturnValue }

}

Is it my environment or my coding?

Thanks!


zarberg@gmail.com


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>