Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows 通过powershell远程安装.net_Windows_Powershell - Fatal编程技术网

Windows 通过powershell远程安装.net

Windows 通过powershell远程安装.net,windows,powershell,Windows,Powershell,我正在尝试通过PowerShell在windows server 2008 r2计算机上远程安装.net framework。了解到这一点似乎无法通过现有的PowerShell会话实现,但需要显式传递凭据(知道为什么吗?)。但是,我仍然收到权限错误 例如,如果我运行: $cred = Get-Credential -Credential 10.20.0.13\administrator $Session=New-PsSession -ComputerName 10.20.0.13 -Creden

我正在尝试通过PowerShell在windows server 2008 r2计算机上远程安装.net framework。了解到这一点似乎无法通过现有的PowerShell会话实现,但需要显式传递凭据(知道为什么吗?)。但是,我仍然收到权限错误

例如,如果我运行:

$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
我可以在安装程序运行的远程计算机上看到(在任务管理器中),临时文件夹是在c:\的根目录上创建的,文件被提取,然后我得到一个700kb的日志文件。在日志文件的底部,我得到:

操作系统版本=6.1.7601,平台2,Service Pack 1操作系统说明= Win2K8R2-x64标准版Service Pack 1命令行= C:\b65da67b927bfb71c84adcecefc019\Setup.exe/q/norestart/log C:\ /x86/x64时区=格林尼治标准时间初始LCID=2057,使用 同时下载和安装机构操作:安装 程序包名称=Microsoft.NET Framework 4安装程序包版本= 4.0.30319用户体验数据收集策略:禁用适用项数:11 (C:\b65da67b927bfb71c84adcecefc019\SetupUtility.exe)成功。Exe 日志文件:dd_SetupUtility.txt ServiceControl操作成功! ServiceControl操作成功!Exe (C:\b65da67b927bfb71c84adcecefc019\Windows6.1-KB958488-v6001-x64.msu) 0x5失败-访问被拒绝。最终结果:安装 失败,错误代码为:(0x00000005),“访问被拒绝。”(已过) 时间:0:00:01:12)。

因此访问被拒绝。但是,使用完全相同的凭据,我可以执行其他任务(在Powershell中添加服务器角色,通过Powershell添加windows功能等),并且我可以使用相同的用户名/密码将RDP添加到该框中,并在该框中运行安装程序(完成得很好)

我在某处遗漏了什么,但似乎找不到是什么。我可以看到它对其他人有用()所以不知道我为什么会得到这个

非常感谢您的帮助


谢谢

您正在创建会话,但从未使用它

我以前没有在远程计算机上尝试过此操作,但尝试使用
-动词RunAs
以“管理员”身份运行该进程,如下所示:

$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

安装.NET framework 4.0时,它还会安装一些更新(.msu)文件


但是当我们远程安装.NET4.0时,由于这些更新,它失败了。原因是,不允许远程安装这些更新。请查找知识库文章。本文还提到了解决方法。

看看这个[SO-answer][1]是否有帮助。[1]: