Install .net framework 4 on remote servers

rated by 0 users
This post has 1 Reply | 1 Follower

Top 50 Contributor
Posts 39
virtuallynothere Posted: 01-25-2012 8:50 AM

Hello,

I am trying to get .net 4 framework installed on remote servers.  I have the script pasted below and I keep running into 2 issues. 

1.  The file will not copy, the file share permissions are fine as I used a separate script that just copies the installer to the remote servers, but in this script the copy fails.

 

2.  The install of .net framework fails with exit code 5 and I am not sure why.  

 

[ScriptBlock] $script = {
    #$ErrorActionPreference = "Stop"
    $MachineName= gc env:computername
    C:\Windows\System32\net.exe use Z: "\\RemoteMachine\SharedFolder\DotnetFrameWork 4.0" password /user:domain\username
    if(!(Test-Path "C:\Temp"))
    {
        New-Item -Path "C:\Temp" -ItemType directory
    }
    Copy-Item -Path "Z:\dotNetFx40_Full_x86_x64.exe" -Destination "C:\Temp" -Force -Recurse    
    function LaunchProcessAndWait([string] $FileName, [string] $CommandLineArgs)
    {
        #preferences
        $ErrorActionPreference="Stop"
        try
        {
            Write-Host "Starting process $FileName on machine $($MachineName)"
            $p = Start-Process -FilePath $FileName -ArgumentList $CommandLineArgs -Wait -PassThru
            Write-Host "The process $FileName exit code is $($p.exitcode)"
            return $p.ExitCode            
        }
        catch
        {
            Write-Host "Error launching process $FileName"
            throw
        }
    }
    LaunchProcessAndWait "C:\Temp\dotNetFx40_Full_x86_x64.exe" "/I /q"
}
$cred = Get-Credential
$sessions = $Hosts | New-PSSession -Credential $cred
Invoke-Command -ScriptBlock $script -Session $sessions
$sessions | Remove-PSSession

Top 10 Contributor
Posts 555
Microsoft MVP
Top Contributor

exit code 5 indicates an "access denied" error.

I admit I did not digest the entire script, but most likely you are running into a permission issue, either when you copy files or when you try and install them.

To be able to run the remote code with full privileges, CredSSP is necessary. Without it, your code runs on behalf of you (with your permissions), but once it needs to authenticate against someone else (like a fileserver to copy the file), it cannot authenticate.

As a workaround to avoid CredSSP, for example you can try and map the fileserver location using "net use" and submit the credentials directly to that command, then use the mapped drive which then no longer requires implicit authentication

So approach these situations similarly, i.e. look for a way to avoid implicit authentication (which would not work without CredSSP) and instead find ways to hand over username and password explicitly in your script.

 

Page 1 of 1 (2 items) | RSS
Concentrated Tech NSoftware Dell Compellent Sponsored by Idera and Concentrated Tech and NSoftware and Dell Compellent
Copyright 2011 PowerShell.com. All rights reserved.