Powershell script runs fine manually but not through SCCM

This topic contains 1 reply, has 2 voices, and was last updated by  Neil Kronberg 1 year, 2 months ago.

  • Author
  • #45146

    Brian Fell

    Looking for some help here. This Powershell script runs fine if I manually run the script but does not run the .Net 461 installation when executed through SCCM 2012. Does anyone know if someone of these commands are not supported through SCCM? Here is my scripts below. Sorry this is my first PowerShell script so I am sure it is pretty ugly 🙂

    This is how I am executing the powershell through SCCM: powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -WindowStyle Hidden -File .\Net461Upgrade.ps1

    #Begin Script
    # Determine script location (Current Directory) for PowerShell
    $ScriptDir = Split-Path $script:MyInvocation.MyCommand.Path

    $strFileName="C:\Program Files\CBP.PortalLauncher\CBP.PortalLauncher.exe"
    $execFile = "NDP461-KB3102436-x86-x64-AllOS-ENU.exe"
    $params = "/norestart", "/q"
    $netDir = "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config"

    #Stop Processes
    kill -processname CBP, DLS, DymoQuickPrint, Dymopnpservice, Screenpresso -Force

    #Backup machine.config before .Net 461 Install

    Copy-Item -Path "$netDir\machine.config" -Destination "$netDir\machine.config.B461" -Force

    #Verify ScriptDir declaration is working and reporting current directory that is expected.
    #Write-Host "Current script directory is $ScriptDir"

    #Run .Net 461 with norestart parameter | Out-Null will make the script to wait until executable is done running before continuing next step of script.
    & $ScriptDir\$execFile $params | Out-Null

    #Check if CBP is installed on PC, if so then overwrite machine.config to repair CBP App
    If (Test-Path $strFileName) {

    #Backup machine.config after .Net 461 Installation
    Copy-Item -Path "$netDir\machine.config" -Destination "$netDir\machine.config.A461" -Force

    #Copy machine.config from current directory after Oracle repair to .Net directory which fixes CBP
    Copy-Item -Path "$ScriptDir\machine.config" -Destination "$netDir" -Force

  • #45152

    Neil Kronberg

    Is it possible to use an application which is dependent upon .NET to upgrade .NET?
    I guess since you were able to run it locally it is... Seems like there would be an issue there though.

    • This reply was modified 1 year, 2 months ago by  Neil Kronberg.

You must be logged in to reply to this topic.