Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am trying to update all of the Windows 7 machines that we have in one of our OUs in Active Directory with either Powershell 3.0 or 4.0. I would like to use either Group Policy or SCCM 2012 and would like it to be pushed as opposed to optional for users to download and install. An issue I've found is the .Net requirement. Is there a way to package the installer so that it installs the required .Net framework if it is not already installed?

share|improve this question
add comment

2 Answers

What you can do in SCCM 2012 is use applications instead of packages.

In your instance, first create the .NET Framework application, then create the Powershell application. When creating the PowerShell application, set a dependency of the applicaion you created called .NET Framework with auto-install checked.

When you deploy the PowerShell application, it will check to see if the workstation has .NET Framework installed. If it is installed, it will go ahead installing PowerShell; if it isn't it will install .NET Framework first.

NOTE: Make sure you set the Detection Method for the .NET application (and PowerShell) so it knows how to check if it's installed.

I use this for .NET 4:

Setting Type: Registry Hive: HKLM Key: SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full Value: Integer "This registry setting must exist on the target system to indicate presence of this application" is checked.

As for pushing to the client, make sure the deployment method is set to Required, NOT Available.

share|improve this answer
add comment

I am not using either of these to install PowerShell 4 but came up with a script to do that. You can get the idea and use bits and pieces that applies to your environment.

    REM Script to upgrade to .net 4.5 & Windows Management Framework 4 (incl. Powershell 4) on Win7 SP1

SETLOCAL ENABLEEXTENSIONS

SET SOURCE=Install_PowerShell4
SET DESTINATION=\\myserver\logs\Inventory\OnDemand\WMF4
SET exeDOTNET45="\\myserver\Packages\Microsoft Dot Net\4.5\dotnetfx45_full_x86_x64.exe" /quiet /norestart
SET exeWMFx64=\\myserver\Packages\WMF4\Windows6.1-KB2819745-x64-MultiPkg.msu /quiet /norestart
SET exeWMFx32=\\myserver\Packages\WMF4\Windows6.1-KB2819745-x86-MultiPkg.msu /quiet /norestart


REM Set Exclusions
REG QUERY HKLM\SOFTWARE\EUDE /V DoNotUpgradeToDotNet45
IF %ERRORLEVEL% EQU 0 GOTO :TAG_EXCEPTION_NET45

REG QUERY HKLM\SOFTWARE\EUDE /V DoNotUpgradeToPowerShell4
IF %ERRORLEVEL% EQU 0 GOTO :TAG_EXCEPTION_PS4

:CONTINUE

:CHECK_FailED
REM If failed before, do not retry.
IF EXIST "%DESTINATION%\Fail_DotNet_%COMPUTERNAME%.txt" GOTO :END
IF EXIST "%DESTINATION%\%COMPUTERNAME%_Has_PowerShell4.txt" GOTO :END
IF EXIST "%DESTINATION%\Success_PowerShell4_%COMPUTERNAME%.txt" GOTO :END

:Check_For_DotNet4.5
REG QUERY "hklm\software\microsoft\net framework setup\ndp\v4\Full" /v Release
If %ERRORLEVEL% EQU 0 GOTO :Has_DotNet45
REM Does not have .net 4.5, need remediation

:Install_DotNet4.5
REM http://msdn.microsoft.com/en-us/library/ee390831.aspx for return codes
cmd /c %exeDOTNET45%
If %ERRORLEVEL% EQU 0 GOTO :DOTNET45_SUCCESS
If %ERRORLEVEL% EQU 1640 GOTO :DOTNET45_SUCCESS
If %ERRORLEVEL% EQU 3010 GOTO :DOTNET45_SUCCESS
REM GOTO :DOTNET45_Fail


:DOTNET45_Fail
    IF NOT EXIST "%DESTINATION%\Fail_DotNet45_%COMPUTERNAME%.txt" ECHO. >"%DESTINATION%\Fail_DotNet45_%COMPUTERNAME%.txt"
GOTO :END


:DOTNET45_SUCCESS
    IF NOT EXIST "%DESTINATION%\Success_DotNet45_%COMPUTERNAME%.txt" ECHO. >"%DESTINATION%\Success_DotNet45_%COMPUTERNAME%.txt"
GOTO :Check_For_PowerShell4


:Has_DotNet45
REM IF NOT EXIST "%DESTINATION%\%COMPUTERNAME%_HasDotNet45.txt" ECHO. >"%DESTINATION%\%COMPUTERNAME%_HasDotNet45.txt"
REM GOTO :Check_For_PowerShell4

:Check_For_PowerShell4
REG QUERY hklm\software\microsoft\powershell\3\PowerShellEngine /v PowerShellVersion |findstr "4"
  IF %ERRORLEVEL% EQU 0 GOTO :Has_PowerShell4
REM Check if we have installed it but waiting for reboot
  IF EXIST "%DESTINATION%\SuccessPendingReboot_PowerShell4_%COMPUTERNAME%.txt" GOTO :END

:Check_Architecture
if /i "%processor_architecture%"=="x86" (
    IF NOT DEFINED PROCESSOR_ARCHITEW6432 ( 
        cmd /c %windir%\System32\wusa.exe %exeWMFx32%   
    ) ELSE (
        cmd /c %windir%\System32\wusa.exe %exeWMFx64%
    )           
) else (
    cmd /c %windir%\System32\wusa.exe %exeWMFx64%
)

If %ERRORLEVEL% EQU 0 GOTO :PowerShell4_SUCCESS
If %ERRORLEVEL% EQU 1640 GOTO :PowerShell4_SUCCESS
If %ERRORLEVEL% EQU 3010 GOTO :PowerShell4_SUCCESS
REM GOTO :PowerShell4_Fail

:PowerShell4_Fail
    IF NOT EXIST "%DESTINATION%\Fail_PowerShell4_%COMPUTERNAME%.txt" ECHO %ERRORLEVEL% >"%DESTINATION%\Fail_PowerShell4_%COMPUTERNAME%.txt"
GOTO :END

:PowerShell4_SUCCESS
    IF NOT EXIST "%DESTINATION%\SuccessPendingReboot_PowerShell4_%COMPUTERNAME%.txt" ECHO. >"%DESTINATION%\SuccessPendingReboot_PowerShell4_%COMPUTERNAME%.txt"
    IF EXIST "%DESTINATION%\Fail_PowerShell4_%COMPUTERNAME%.txt" del /f /q "%DESTINATION%\Fail_PowerShell4_%COMPUTERNAME%.txt"
GOTO :END

:Has_PowerShell4
REM  IF EXIST "%DESTINATION%\SuccessPendingReboot_PowerShell4_%COMPUTERNAME%.txt" (
    IF EXIST "%DESTINATION%\Fail_PowerShell4_%COMPUTERNAME%.txt" del /f /q "%DESTINATION%\Fail_PowerShell4_%COMPUTERNAME%.txt"
    IF EXIST "%DESTINATION%\WindowsUpdateStopped_%COMPUTERNAME%.txt" del /f /q "%DESTINATION%\WindowsUpdateStopped_%COMPUTERNAME%.txt"
    del /f /q "%DESTINATION%\SuccessPendingReboot_PowerShell4_%COMPUTERNAME%.txt"
    ECHO. >"%DESTINATION%\Success_PowerShell4_%COMPUTERNAME%.txt"
REM  ) ELSE (
REM     ECHO. >"%DESTINATION%\%COMPUTERNAME%_Has_PowerShell4.txt"
REM  )



GOTO :END

:TAG_EXCEPTION_NET45
IF NOT EXIST "%DESTINATION%\DoNotUpgradeToDotNet45_%COMPUTERNAME%.txt" (
    eventcreate /L "APPLICATION" /T Information /SO "%SOURCE%" /id 779 /d "Tagged with DoNotUpgradeToDotNet45"
    ECHO. >"%DESTINATION%\DoNotUpgradeToDotNet45_%COMPUTERNAME%.txt"
)
GOTO :END

:TAG_EXCEPTION_PS4
IF NOT EXIST "%DESTINATION%\DoNotUpgradeToPowerShell4_%COMPUTERNAME%.txt" (
    eventcreate /L "APPLICATION" /T Information /SO "%SOURCE%" /id 779 /d "Tagged with DoNotUpgradeToPowerShell4"
    ECHO. >"%DESTINATION%\DoNotUpgradeToPowerShell4_%COMPUTERNAME%.txt"
)
GOTO :END

:WindowsUpdateStopped
IF NOT EXIST "%DESTINATION%\WindowsUpdateStopped_%COMPUTERNAME%.txt" (
    ECHO. >"%DESTINATION%\WindowsUpdateStopped_%COMPUTERNAME%.txt"
)
GOTO :END

:END
ENDLOCAL
Exit /b
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.