简体   繁体   中英

Install .net remotely via powershell

I'm attempting to install the .net framework on a windows server 2008 r2 machine remotely via PowerShell. Reading about it seems that this cannot be achieved through an existing PowerShell session but credentials need to be explicitly passed in (any idea why this is?). However, I'm still getting permission errors.

For example, If I run:

$cred = Get-Credential -Credential 10.20.0.13\administrator
$Session=New-PsSession -ComputerName 10.20.0.13 -Credential $cred
Invoke-command -ScriptBlock {Start-Process -FilePath c:\installers\dotNetFx40_Full_x86_x64.exe  -ArgumentList "/q /norestart /log c:\" -Wait} -Credential $cred -ComputerName 10.20.0.13

I can see on the remote machine that the installer runs (in task manager), the temporary folder is created on the root of c:\\, the files extracted and then I get a 700kb log file. At the foot of that log file I get:

OS Version = 6.1.7601, Platform 2, Service Pack 1 OS Description = Win2K8R2 - x64 Standard Edition Service Pack 1 CommandLine = C:\\b65da67b927bfb71c84adcecefc019\\Setup.exe /q /norestart /log c:\\ /x86 /x64 TimeZone = GMT Standard Time Initial LCID = 2057 Using Simultaneous Download and Install mechanism Operation: Installing Package Name = Microsoft .NET Framework 4 Setup Package Version = 4.0.30319 User Experience Data Collection Policy: Disabled Number of applicable items: 11 Exe (C:\\b65da67b927bfb71c84adcecefc019\\SetupUtility.exe) succeeded. Exe Log File: dd_SetupUtility.txt ServiceControl operation succeeded! ServiceControl operation succeeded! Exe (C:\\b65da67b927bfb71c84adcecefc019\\Windows6.1-KB958488-v6001-x64.msu) failed with 0x5 - Access is denied. . Final Result: Installation failed with error code: (0x00000005), "Access is denied. " (Elapsed time: 0 00:01:12).

So access is denied. However, using the exact same credentials I can perform other tasks (add server roles in Powershell, add windows features via powershell etc) and I can RDP onto the box using the same username/password and run the installer there (which completes fine).

I'm missing something somewhere, but can't seem to find out what it is. I can see its worked for someone else ( http://social.technet.microsoft.com/Forums/windowsserver/ar-SA/3045eb24-7739-4695-ae94-5aa7052119fd/install-dotnet-framework-4-using-powershell?forum=winserverpowershell ) so no idea why I'm getting this.

Any help much appreciated.

Thanks

You're creating a session but never using it?

I haven't tried this on a remote computer beforey, but try to run the process "as admin" by using -Verb RunAs , like this:

$cred = Get-Credential -Credential 10.20.0.13\administrator
$Session=New-PsSession -ComputerName 10.20.0.13 -Credential $cred
Invoke-command -ScriptBlock {Start-Process -FilePath c:\installers\dotNetFx40_Full_x86_x64.exe  -ArgumentList "/q /norestart /log c:\" -Wait -Verb RunAs } -Session $Session

While installation of .NET framework 4.0, It installs some updates as well (.msu) files.

But when we are installaing .NET 4.0 remotely, It fails because of these updates. The reason behind that is, it's not allowable to install these updates remotely. Please find the KB article here . This article also mentioned the workaround for this.

you have servername in textfile or machine names in OU based. create .bat which has .exe to run C:\\temp\\xxx.exe /S /qn

$ou='OU=subou3,OU=subou2,OU=subou1,DC=domain,DC=com' $filter = @("machinename1", "machinename2") $compute= Get-ADComputer -Filter * -SearchBase $ou | where-object{$filter -contains $_.name} $comp=$compute.name

foreach ($Computer in $Comp) {

Write-Host "Processing $Computer"

{ Write-Host " Installing application on $Comp"

    psexec $Compter path\XXX.bat /S /qn}}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM