Script resource for installing .Net frameworks

This topic contains 3 replies, has 3 voices, and was last updated by Profile photo of Feldmann Pascal Feldmann Pascal 1 year, 11 months ago.

  • Author
    Posts
  • #19736
    Profile photo of Michael Craig
    Michael Craig
    Participant

    Hello,

    I posted on another thread, but thought I should create a separate topic for this instead.
    So, I have written a custom Script resource to install .net 4.5.2. The steps in the SetScript portion work when executed in Powershell.
    When run under DSC, however, the .Net installer does not get invoked. I've watched Task Manager to make sure.
    I've tried 3 different ways to invoke the installer, you will see that 2 of them are currently commented out.

    Since the silent install of .net 4.5.2, when invoked, returns immediately, I've included a check to determine when the install is completed.
    Again, this all works outside of DSC.

    Help Please?
    (pre)
    SetScript = {
    $filename = "NDP452-KB2901907-x86-x64-AllOS-ENU.exe"
    $httpdownload = "http://download.microsoft.com/download/E/2/1/E21644B5-2DF2-47C2-91BD-63C560427900/NDP452-KB2901907-x86-x64-AllOS-ENU.exe"
    $NetBuildVersion = "379893"

    $DnsDomain = (Get-WmiObject Win32_ComputerSystem).domain

    write-verbose "DnsDomain: $DnsDomain"

    switch -wildcard ($DnsDomain)
    {
    "lab*" { $binpath="\\chelchengat10\public\FileShare\dotNetRedist\$filename"}
    "labtest*" { $binpath="\\chclappadfs02\cct_ops\DeploymentAutomation\bin\hotfixes\$filename"}
    default {$binpath="\\n\a"}
    }

    if (!(test-path $binpath)){
    invoke-webrequest $httpdownload -OutFile C:\binroot\$filename
    $binpath="c:\binroot\$filename"
    }

    write-verbose "Install Net 4.5.2 from $binpath"
    write-verbose "Executing $binpath /q /norestart"

    sleep 5

    #Start-Process -FilePath $binpath -ArgumentList "/q /norestart" -Wait
    #Invoke-Expression -Command "$binpath /q /norestart"
    &$binpath "/q" "/norestart"

    while ($isInstalled -ne $true){

    if (Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full' | %{$_ -match 'Release'}){
    if (( Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full').Release -le $NetBuildVersion){$isInstalled = $false}else{$isInstalled=$true}
    }
    write-verbose "Net 4.5.2 Installed Yet?: $isInstalled"
    sleep 5
    }

    }(/pre)

  • #19740
    Profile photo of Daniel Krebs
    Daniel Krebs
    Participant

    Michael,

    I assume you're pushing this configuration. Please run Start-DscConfiguration with the -Wait and -Verbose switches and attached the relevant parts of the verbose output for the Script resource to this thread. Do you have a TestScript which returns $false if .NET 4.5 is not installed?

    Best,
    Daniel

  • #19742
    Profile photo of Michael Craig
    Michael Craig
    Participant

    Yes, I'm running this directly on my 'dev' workstation to verify configuration before I apply to another server.

    (pre)
    VERBOSE: [DEV001]: LCM: [ Start Resource ] [[Script]net451Install]
    VERBOSE: [DEV001]: LCM: [ Start Test ] [[Script]net451Install]
    VERBOSE: [DEV001]: LCM: [ End Test ] [[Script]net451Install] in 0.1090 seconds.
    VERBOSE: [DEV001]: LCM: [ Skip Set ] [[Script]net451Install]
    VERBOSE: [DEV001]: LCM: [ End Resource ] [[Script]net451Install]
    VERBOSE: [DEV001]: LCM: [ Start Resource ] [[Script]net452Install]
    VERBOSE: [DEV001]: LCM: [ Start Test ] [[Script]net452Install]
    VERBOSE: [DEV001]: LCM: [ End Test ] [[Script]net452Install] in 0.0160 seconds.
    VERBOSE: [DEV001]: LCM: [ Start Set ] [[Script]net452Install]
    VERBOSE: [DEV001]: [[Script]net452Install] DnsDomain: lab.net
    VERBOSE: [DEV001]: [[Script]net452Install] Install Net 4.5.2 from \\server\public\FileShare\dotNetRedist\NDP452-KB2901907-x86-x64-AllOS-ENU.exe
    VERBOSE: [DEV001]: [[Script]net452Install] Executing \\server\public\FileShare\dotNetRedist\NDP452-KB2901907-x86-x64-AllOS-ENU.exe /q /norestart
    VERBOSE: [DEV001]: [[Script]net452Install] Net 4.5.1 Installed Yet?: False
    VERBOSE: [DEV001]: [[Script]net452Install] Net 4.5.1 Installed Yet?: False
    VERBOSE: [DEV001]: [[Script]net452Install] Net 4.5.1 Installed Yet?: False
    VERBOSE: [DEV001]: [[Script]net452Install] Net 4.5.1 Installed Yet?: False
    (/pre)

    See attached for full resource text.

  • #21071
    Profile photo of Feldmann Pascal
    Feldmann Pascal
    Participant

    Hi

    I'm new here. But I also look into how to install the .Net 4.5.2 Framework.

    Your script seems not run just by itself.

    When i run the script from above I get the error "The term "Script" is not recognized as the name of a cmdlet".

    Can you privide more info how to run the script above?

    Thanks

You must be logged in to reply to this topic.