azure - DevOps 注册脚本错误 : Current() ). IsInRole(...)

标签 azure iis deployment devops vps

我无法让我的注册脚本在 PowerShell (admin) 中运行。它可以在 Powershell ISE 中运行,但随后脚本卡在“正在连接到服务器...”

我做错了什么吗?

enter image description here

这是脚本:

 $ErrorActionPreference="Stop";If(-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent() ).IsInRole( [Security.Principal.WindowsBuiltInRole] “Administrator”)){ throw "Run command in an administrator PowerShell prompt"};If($PSVersionTable.PSVersion -lt (New-Object System.Version("3.0"))){ throw "The minimum version of Windows PowerShell that is required by the script (3.0) does not match the currently running version of Windows PowerShell." };If(-NOT (Test-Path $env:SystemDrive\'azagent')){mkdir $env:SystemDrive\'azagent'}; cd $env:SystemDrive\'azagent'; for($i=1; $i -lt 100; $i++){$destFolder="A"+$i.ToString();if(-NOT (Test-Path ($destFolder))){mkdir $destFolder;cd $destFolder;break;}}; $agentZip="$PWD\agent.zip";$DefaultProxy=[System.Net.WebRequest]::DefaultWebProxy;$securityProtocol=@();$securityProtocol+=[Net.ServicePointManager]::SecurityProtocol;$securityProtocol+=[Net.SecurityProtocolType]::Tls12;[Net.ServicePointManager]::SecurityProtocol=$securityProtocol;$WebClient=New-Object Net.WebClient; $Uri='[url]';if($DefaultProxy -and (-not $DefaultProxy.IsBypassed($Uri))){$WebClient.Proxy= New-Object Net.WebProxy($DefaultProxy.GetProxy($Uri).OriginalString, $True);}; $WebClient.DownloadFile($Uri, $agentZip);Add-Type -AssemblyName System.IO.Compression.FileSystem;[System.IO.Compression.ZipFile]::ExtractToDirectory( $agentZip, "$PWD");.\config.cmd --deploymentgroup --deploymentgroupname "Production" --agent $env:COMPUTERNAME --runasservice --work '_work' --url '[devopsUrl]' --projectname 'Storms' --auth PAT --token [token]; Remove-Item $agentZip;

最佳答案

引号是问题所在。引号有多种类型,根据您居住的国家/地区,这可能会导致问题。

可以通过删除“管理员”周围的引号并手动将其添加回来来解决此问题。

您可以在这里看到差异: “管理员”与“管理员”

注意到引号中的区别了吗?第一对是美国版,第二对是欧洲版。

关于azure - DevOps 注册脚本错误 : Current() ). IsInRole(...),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71148132/

相关文章:

c# - Azure Functions 绑定(bind)不起作用

IIS 6/COM+ 挂起

asp.net - 具有 Windows 身份验证的 IIS 7.5 Web 应用程序是否需要最终用户具有文件权限?

node.js - 使用 pm2 启动 sails 应用程序时出错

iis - 部署后自动启动Azure webrole

excel - 我的 VBA 代码未将 csv 文件上传到 Azure 中的 ADLS

Azure Log Analytics switch 语句/模式匹配

c# - 如何在 IE 已从登录保护的 Intranet 打开的 Office 文档中启用编辑?

deployment - 尝试使用 TeamCity 8 部署 SSDT 项目时文件名无效

c# - Azure 服务总线 ReceiveBatch 返回 0 条消息