none
Copying and installing an MSI to multiple computers RRS feed

  • Question

  • Hello, I'm trying to troubleshoot this script. Any help would be appreciated.

    The first error I'm getting is "Access Denied" when attempting to copy the .msi file. The file path gets created but then the file doesn't copy. I've checked the permissions on the folder and they appear to be correct.  Also, the folders are created with the ReadOnly attribute.

    The next error I get is:

    Connecting to remote server servername failed with the following error message : WinRM cannot complete the operation. Verify that the specified computer name is valid, that the computer is accessible over the network, and that a firewall exception for the WinRM service is enabled and allows access from this computer. By default, the WinRM firewall exception for public profiles limits access to remote computers within the same local subnet. For more information, see the about_Remote_Troubleshooting Help topic.  I've even made sure the WinRM service was started on the remote machine.  The firewall is not running on the domain profile.

    + CategoryInfo : OpenError: (servername:String) [], PSRemotingTransportException

    + FullyQualifiedErrorId : WinRMOperationTimeout,PSSessionStateBroken

    $computername = Get-Content 'c:\temp\comp.txt'
    $sourcefile = "\\servername\share\test.msi"
    #This section will install the software
    foreach ($computer in $computername)
    {
        $destinationFolder = "\\$computer\C$\download"
        #This section will copy the $sourcefile to the $destinationfolder. If the Folder does not exist it will create it.
        if (!(Test-Path -path $destinationFolder))
        {
            New-Item $destinationFolder -Type Directory           
        }
        Copy-Item -Path $sourcefile -Destination $desinationfolder -Force
        Invoke-Command -ComputerName $computer -ScriptBlock { & cmd /c "msiexec.exe /i c:\download\test.msi" /qb}
    }
     


    D Cobb Windows IT Pro


    Monday, January 27, 2014 9:54 PM

Answers

  • Thank you jrv. I was able to clean it up a bit and then it worked.

    Here is the final:

    $InstallString ="cmd /c 'msiexec /i C:\Directory\Install.msi'"
    $computer='remotepc.txt'
    ([WMICLASS]"\\$Computer\ROOT\CIMV2:Win32_Process").Create($InstallString)

    The msi file I was working with didn't like the /quiet switch.  Also, when I added the FQDN of the machines in the text file, it didn't throw back any errors.

    In my initial inquiry, I was never able to get copy-item to work for me so I ended up using robocopy from the cmd prompt to copy the file to the computers. robocopy \\sourcefile\dir \\destination\dir install.msi


    D Cobb Windows IT Pro


    Wednesday, February 12, 2014 12:38 AM

All replies

  • Don't use a script. Use group policy.

    Bill

    Monday, January 27, 2014 10:53 PM
    Moderator
  • Hello Bill,

    Thanks for the response.  Using Group Policy is not an option for me at this time.


    D Cobb Windows IT Pro


    Tuesday, January 28, 2014 2:39 PM
  • Then I would recommend copying the MSI package to each machine and install locally. You can use the Task Scheduler to initiate the installer. Make sure to run the installation silently.

    Bill

    Tuesday, January 28, 2014 3:17 PM
    Moderator
  • Bill,

    Is there a way to do what I'm trying to do in Powershell?  I'm still trying to get my script to work?


    D Cobb Windows IT Pro


    Friday, January 31, 2014 8:29 PM
  • Bill,

    Is there a way to do what I'm trying to do in Powershell?  I'm still trying to get my script to work?


    D Cobb Windows IT Pro


    Use WMI Win32_Process to create a remote process.  This will work if your systems are set up correctly and if the MSI is designed for total quiet install.  Many MSI installs are not designed for true unattended installs so you will need to test carefully.


    ¯\_(ツ)_/¯

    Friday, January 31, 2014 8:33 PM
  • I'm a scripting newby working to find my way :-)  I saw this on a post and tried it:

    $InstallString = "msiexec /i `"C:\Directory\Install.msi`"
    ([WMICLASS]"\\$Computer\ROOT\CIMV2:Win32_Process").Create($InstallString)

    but got the error

    Cannot convert value "\\\root\win32_process" to type "System.Management.ManagementClass". Error: "Invalid parameter "
    At line:39 char:67
    + Get-Content c:\temp\result2.txt | Foreach-Object {([wmiclass]"\\$($_.trim())\roo ...
    + ~~~~~~~~~
    + CategoryInfo : InvalidArgument: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvalidCastToWMIClass

    I'm using PS v3 by the way


    D Cobb Windows IT Pro



    Friday, January 31, 2014 8:42 PM
  • Hi,

    Here's an old thread with one way to do remote installations:

    http://social.technet.microsoft.com/Forums/windowsserver/en-US/4842b5e9-b0cb-435d-99d2-ef3d735a75d4/powershell-installing-exe-remotely-maybe-double-hop-error-or-bad-scripting?forum=winserverpowershell

    Granted, we were cheating by using a batch file to call the installer, but it did the trick. You'll need to adjust it for use with MSIs and you'll need to ensure that remoting is enabled across your domain (or at the very least where you want to be able to run this script).


    Don't retire TechNet! - (Don't give up yet - 12,575+ strong and growing)

    Friday, January 31, 2014 8:52 PM
  • $computer has to have the remote computer name.

    you also should not use the wrong quotes.

    $InstallString ='msiexec /i C:\Directory\Install.msi /quiet'
    $computer='remotepc'
    ([WMICLASS]"\\$Computer\ROOT\CIMV2:Win32_Process").Create($InstallString)


    ¯\_(ツ)_/¯



    • Edited by jrv Friday, January 31, 2014 8:59 PM
    Friday, January 31, 2014 8:58 PM
  • Thank you jrv. I was able to clean it up a bit and then it worked.

    Here is the final:

    $InstallString ="cmd /c 'msiexec /i C:\Directory\Install.msi'"
    $computer='remotepc.txt'
    ([WMICLASS]"\\$Computer\ROOT\CIMV2:Win32_Process").Create($InstallString)

    The msi file I was working with didn't like the /quiet switch.  Also, when I added the FQDN of the machines in the text file, it didn't throw back any errors.

    In my initial inquiry, I was never able to get copy-item to work for me so I ended up using robocopy from the cmd prompt to copy the file to the computers. robocopy \\sourcefile\dir \\destination\dir install.msi


    D Cobb Windows IT Pro


    Wednesday, February 12, 2014 12:38 AM