Msbuild 在一组计算机上使用WinRM安装/更新Microsoft Visual Studio生成工具15或16

Msbuild 在一组计算机上使用WinRM安装/更新Microsoft Visual Studio生成工具15或16,msbuild,winrm,Msbuild,Winrm,我尝试使用WinRM自动更新msbuil工具版本15.xx和16.xx,但没有成功。我尝试了许多变化,但仍然没有安装或更新 #为WinRM创建凭据 $password=ConvertTo SecureString'pwd'-AsPlainText-Force $cred=新对象System.Management.Automation.PSCredential('domain\user',$password) #创建将在一组计算机上执行的命令 $command={ #定义并创建存储安装程序的路径

我尝试使用
WinRM
自动更新
msbuil工具
版本
15.xx
16.xx
,但没有成功。我尝试了许多变化,但仍然没有安装或更新

#为WinRM创建凭据
$password=ConvertTo SecureString'pwd'-AsPlainText-Force
$cred=新对象System.Management.Automation.PSCredential('domain\user',$password)
#创建将在一组计算机上执行的命令
$command={
#定义并创建存储安装程序的路径
$path='C:\WinRM'
如果(!(测试路径$path))
{
新建项-ItemType目录-Force-Path$Path
}
#下载安装程序
调用webrequest-uri'https://aka.ms/vs/15/release/vs_buildtools.exe'-OutFile'C:\WinRM\vs_buildtools2017.exe'
调用webrequest-uri'https://aka.ms/vs/16/release/vs_buildtools.exe'-OutFile'C:\WinRM\vs_buildtools2019.exe'
#尝试更新…无人工作
#启动进程“C:\WinRM\vs_buildtools2017.exe”-ArgumentList'--更新--安静--等待”
#启动进程“C:\WinRM\vs_buildtools2019.exe”-nonewindow-ArgumentList“安装--等待--被动--norestart--安装路径”C:\Program Files(x86)\Microsoft Visual Studio\2019\BuildTools“
#启动进程“C:\WinRM\vs_buildtools2017.exe”-ArgumentList”更新--等待--安静--norestart--安装路径“C:\Program Files(x86)\Microsoft Visual Studio\2017\BuildTools”}
#启动进程“C:\WinRM\vs_buildtools2019.exe”-ArgumentList”-添加Microsoft.VisualStudio.Workload.MSBuildTools--安静”
#启动进程“C:\WinRM\vs_buildtools2019.exe”
}
调用命令-ComputerName(获取内容。\Machines.txt)-ScriptBlock$Command-Credential$cred
我真的不知道我做错了什么。
谢谢。

我想我找到了解决办法

$password=ConvertTo SecureString'pwd'-AsPlainText-Force
$cred=新对象System.Management.Automation.PSCredential('domain\user',$password)
$command={
$path='C:\WinRM'
如果(!(测试路径$path))
{
新建项-ItemType目录-Force-Path$Path
}
$pc=$env:computername
#使用导出的配置下载配置文件
net使用'\\share.domain.local\something'/user:'domain\user''pwd'
复制项目-Path'\\share.domain.local\fromPath\.vsconfig'-Recurse-Destination'C:\WinRM\.vsconfig'-Container-Force
写入主机“[“$pc”]=>>”文件“.vsconfig”已写入”
#下载MSBuild 2017的生成工具安装程序
调用webrequest-uri'https://aka.ms/vs/15/release/vs_buildtools.exe'-OutFile'C:\WinRM\vs_buildtools2017.exe'
写入主机“[“$pc”]=>>”文件“vs_buildtools2017”已写入
#下载MSBuild 2019的生成工具安装程序
调用webrequest-uri'https://aka.ms/vs/16/release/vs_buildtools.exe'-OutFile'C:\WinRM\vs_buildtools2019.exe'
写入主机“[“$pc”]=>>”文件“vs_buildtools2019”已写入
写入主机“[“$pc”]=>>”“构建工具->'vs_buildtools2019'->安装”
$exitCode=启动进程'C:\WinRM\vs_buildtools2019.exe'-ArgumentList”--config、“-quiet”、“-norestart”、“-wait”--wait-PassThru
#写入主机$exitCode |选择对象
写入主机“[“$pc”]=>>”生成工具->'vs_buildtools2019'->已安装”
写入主机“[“$pc”]=>>”“生成工具->'vs_buildtools2017'->更新”
$exitCode=启动进程'C:\WinRM\vs_buildtools2017.exe'-参数列表“更新”、“--quiet”、“--norestart”、“--wait”-wait-PassThru
#写入主机$exitCode |选择对象
写入主机“[“$pc”]=>>”“生成工具->'vs_buildtools2017'->已更新”
写入主机“[“$pc”]=>>”“构建工具->'vs_buildtools2019'->更新”
$exitCode=启动进程'C:\WinRM\vs_buildtools2019.exe'-参数列表“更新”、“--quiet”、“--norestart”、“--wait”-wait-PassThru
#写入主机$exitCode |选择对象
写入主机“[“$pc”]=>>”“生成工具->'vs_buildtools2019'->已更新”
写入主机“[“$pc”]=>>”“
重新启动计算机-计算机名称$pc-强制
}
调用命令-ComputerName(获取内容。\Machines\u all.txt)-ScriptBlock$Command-Credential$cred

我想我找到了解决办法

$password=ConvertTo SecureString'pwd'-AsPlainText-Force
$cred=新对象System.Management.Automation.PSCredential('domain\user',$password)
$command={
$path='C:\WinRM'
如果(!(测试路径$path))
{
新建项-ItemType目录-Force-Path$Path
}
$pc=$env:computername
#使用导出的配置下载配置文件
net使用'\\share.domain.local\something'/user:'domain\user''pwd'
复制项目-Path'\\share.domain.local\fromPath\.vsconfig'-Recurse-Destination'C:\WinRM\.vsconfig'-Container-Force
写入主机“[“$pc”]=>>”文件“.vsconfig”已写入”
#下载MSBuild 2017的生成工具安装程序
调用webrequest-uri'https://aka.ms/vs/15/release/vs_buildtools.exe'-OutFile'C:\WinRM\vs_buildtools2017.exe'
写入主机“[“$pc”]=>>”文件“vs_buildtools2017”已写入
#下载MSBuild 2019的生成工具安装程序
调用webrequest-uri'https://aka.ms/vs/16/release/vs_buildtools.exe'-OutFile'C:\WinRM\vs_buildtools2019.exe'
写入主机“[“$pc”]=>>”文件“vs_buildtools2019”已写入
写入主机“[“$pc”]=>>”“构建工具->'vs_buildtools2019'->安装”
$exitCode=启动进程'C:\WinRM\vs_buildtools2019.exe'-ArgumentList”--config、“-quiet”、“-norestart”、“-wait”--wait-PassThru
#写入主机$exitCode |选择对象
写入主机“[“$pc”]=>>”生成工具->'vs_buildtools2019'->已安装”
写入主机“[“$pc”]=>>”“生成工具->'vs_buildtools2017'->更新”
$exitCode=启动进程'C:\WinRM\vs_buildtools2017.exe'-参数列表“更新”、“--quiet”、“--norestart”、“--wait”-wait-PassThru
#写入主机$exitCode |选择对象
写居屋