问题描述
我正在使用自定义脚本扩展 (CSE) 在 Windows 虚拟机中设置代理,然后安装防病毒解决方案。防病毒解决方案设置需要互联网连接。但似乎在 CSE 配置期间,代理配置并未立即生效,因此防病毒安装失败。这是我的代理设置脚本:
Set-ItemProperty -Path 'HKLM:\Software\Policies\Microsoft\Windows\CurrentVersion\Internet Settings' -name ProxySettingsPerUser -Value 0
Set-ItemProperty -Path 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Internet Settings' -name ProxyServer -Value "123.123.123.123:80"
Set-ItemProperty -Path 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Internet Settings' -name ProxyEnable -Value 1
netsh winhttp set proxy 123.123.123.123:80
在 CSE 配置之后,当我连接到虚拟机时,我看到代理设置正确并且能够访问互联网。此外,可以通过手动启动脚本来安装防病毒解决方案。我的问题是在 CSE 配置期间代理配置没有立即生效,并且由于没有互联网,杀毒软件失败。
以下是 CSE 部署政策声明的一部分:
"resources": [
{
"apiVersion": "2015-06-15","copy": {
"count": "[length(variables('vmListArray'))]","name": "avAgentcopy"
},"location": "[parameters('vmLocation')]","name": "[concat(trim(variables('vmListArray')[copyIndex()]),'/AntivirusAgent')]","properties": {
"autoUpgradeMinorVersion": true,"protectedSettings": {
"commandToExecute": "[concat ('powershell -ExecutionPolicy Unrestricted -File \"./Scripts/installation-proxy-windows.ps1\" && powershell -ExecutionPolicy Unrestricted -File \"./Scripts/installation-antivirus-windows.ps1\" ')]","storageAccountKey": "mykey","storageAccountName": "mystorageaccount"
},"publisher": "Microsoft.Compute","settings": {
"fileUris": "[split(variables('fileUris'),' ')]"
},"type": "CustomScriptExtension","typeHandlerVersion": "1.7"
},"type": "Microsoft.Compute/virtualMachines/extensions"
}
],"variables": {
"fileUris": "https://mystorageaccount.blob.core.windows.net/mycontainer/Scripts/installation-antivirus-windows.ps1 https://mystorageaccount.blob.core.windows.net/mycontainer/Scripts/installation-proxy-windows.ps1","vmListArray": "[split(parameters('vmList'),',')]"
}
所以我的问题是为什么自定义脚本扩展代理设置不会立即生效?有没有办法克服这个问题或替代方法?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)