Install Software Remotely over Either

I am automating the configuration of my 2012 servers and I need to figure out how to install the applications using remoting.  

I was able to get them to run using PowerShell locally, I think using:

Start-Process -FilePath C:\SystemProvisioning\BGInfo\BGInfoProd-Ver2\InstallProduction.vbs
Start-Process -FilePath C:\SystemProvisioning\Maint2.0_reg_files\MW_PRD_Friday_10pm.reg 
Start-Process -FilePath C:\SystemProvisioning\SCCM2012client\install-close-window.bat
Start-Process -FilePath C:\SystemProvisioning\SCOM\agent\SCOM_2012R2_Agent_Install.cmd
Start-Process -FilePath C:\SystemProvisioning\Scripts\RunPCI_Updates1.cmd
Start-Process -FilePath C:\SystemProvisioning\SEP\RunSEPinstall.cmd
But maybe I will need different techniques depending on the type of config or install.  As you can see, the previous guy made .cmd and bat files for most of the installs.
The one I am trying to figure out right now is the .reg.
$Svrconf = New-PSSession -ComputerName -Credential $cred -Name Svrconf
Invoke-Command -Session $Svrconf -ScriptBlock {C:\SystemPro\Maint2.0_reg_files\MW_PRD_Friday_10pm.reg}
Invoke-Command -Session $Svrconf -ScriptBlock {Set-Location HKLM:\SYSTEM\test | out-null
Get-ItemProperty .\TT_ServerOperations\Maintenance | select ttMaintCollectionName}
The second command is just to see if the setting changed, it did not.  There are 20 of these to choose from, so If I don't have to rewrite them all in PowerShell, for now, that would be great.
What about the other one's, will Invoke-command spin up .bat and .cmd?
I just read a few older thread and found this:
(Start-Process -FilePath "msiexec.exe" -ArgumentList "<<whatever>>" -Wait -Passthru).ExitCode
This is what I used above, but it doesn't address my need to do this remotely.  
I am trying to automate
  • You can try this


    Invoke-Command -Session $Svrconf -ScriptBlock { csript.exe "C:\SystemProvisioning\BGInfo\BGInfoProd-Ver2\InstallProduction.vbs}
    Invoke-Command -Session $Svrconf -ScriptBlock { Invoke-expression "C:\SystemProvisioning\Maint2.0_reg_files\MW_PRD_Friday_10pm.reg"}
    Invoke-Command -Session $Svrconf -ScriptBlock { Invoke-expression "C:\SystemProvisioning\SCCM2012client\install-close-window.bat"}
    Invoke-Command -Session $Svrconf -ScriptBlock { Invoke-expression "C:\SystemProvisioning\SCOM\agent\SCOM_2012R2_Agent_Install.cmd"}
    Invoke-Command -Session $Svrconf -ScriptBlock { Invoke-expression "C:\SystemProvisioning\Scripts\RunPCI_Updates1.cmd"}
    Invoke-Command -Session $Svrconf -ScriptBlock { Invoke-expression "C:\SystemProvisioning\SEP\RunSEPinstall.cmd"}

  • I will try it today, and let you know, thanks!

  • Ok, Trying to get the .reg file to run seems to not work because when I run that, it come up with a box that asks:

    Adding information can unintentionally change or delete values and cause components to stop working correctly. Are you sure you want to continue?

    Is there a way to run this from the command prompt so it doesn't ask this question?

    Invoke-Command -Session $Svrconf -ScriptBlock { Start-Process -FilePath "C:\SystemProvisioning\Maint2.0_reg_files\MW_PRD_Friday_10pm.reg"}

    I think it would work if I can overcome that prompt.

  • You could try the below command to avoid the prompt of confirmation

    Invoke-Command -Session $Svrconf -ScriptBlock { Invoke-Expression  "regedit /s C:\SystemProvisioning\Maint2.0_reg_files\MW_PRD_Friday_10pm.reg"} and please make sure powershell is running in administrator mode.

    Even powershell itself provide the cmdlets to edit the registry directly you can try your hands on them as well.

  • You are a rock start!  That worked.  I did not want to have to rebuild all the existing reg files with PowerShell commands if I did not have to.  Thanks!

    Do you mind taking a look at another post of mine, "Reseting passwords on remote domian using Native Commands"?  See if you have any ideas?