简体   繁体   English

Windows PowerShell设置脚本未执行

[英]WIndows PowerShell provisioning script not being executed

I'm deploying a Windows 2012 R2 VSI and need to be able to manage it using Ansible. 我正在部署Windows 2012 R2 VSI,需要能够使用Ansible对其进行管理。

I'm using this Ansible sample script ConfigureRemotingForAnsible.ps1 although renamed and have the script hosted on SL Object storage. 我正在使用此Ansible示例脚本ConfigureRemotingForAnsible.ps1,尽管已重命名并将脚本托管在SL Object存储上。 I specify a postinstall script URL including https (which is supposed to cause the execution of the script after downloading) during the order. 我在订单期间指定了一个包括https (应该在下载后导致脚本执行)的后安装脚本URL。

After the Windows VSI is ready I attempt to run a win-ping as follows: Windows VSI准备就绪后,我尝试按以下方式运行win-ping

- name: ad1 ready gather_facts: false tags: setup hosts: ad1 tasks: - name: ping the windows vsi win_ping:

This fails with the output: 输出失败:

fatal: [169.55.189.16]: UNREACHABLE! => {"changed": false, "msg": "ssl: HTTPSConnectionPool(host='169.55.189.16', port=5986): Max retries exceeded with url: /wsman (Caused by NewConnectionError('<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x107c0b310>: Failed to establish a new connection: [Errno 61] Connection refused',))", "unreachable": true}

If I connect to the system and look in c:\\PostInstall I see my script has been downloaded. 如果我连接到系统并查看c:\\PostInstall ,则看到我的脚本已下载。 If I then open a PowerShell and run the script, I am able to then run the above win-ping successfully. 如果随后打开PowerShell并运行脚本,则可以成功运行上述win-ping

This tells me that the script is downloaded cleanly and is apparently correct, but is not being executed in spite of the https in the postinstall URL. 这告诉我该脚本是干净下载的,而且显然是正确的,尽管安装后URL中带有https ,但该脚本执行。

I can't find any documentation on requirements of the postinstall script for windows, but I'm wondering if the problem is that I'm using a PowerShell script, and that the post provision process tries to run this in a standard CMD shell. 我找不到有关Windows的后安装脚本要求的任何文档,但是我想知道问题是否出在我使用的是PowerShell脚本,并且后置配置过程试图在标准CMD Shell中运行该脚本。

Does anyone have any ideas or thoughts on what could be wrong? 是否有人对可能出什么问题有任何想法或想法?

It should work with powershell succesfully, you should be able to see the logs of the powershell execution in "C:\\postInstallScript.log" perhaps it contains more information about the error. 它应该可以成功地与Powershell一起使用,您应该能够在“ C:\\ postInstallScript.log”中看到Powershell执行的日志,也许它包含有关该错误的更多信息。

Anyway if you are still facing this issue I suggest you to open a ticket in Softlayer with "hardware issue" subject, because the issue is likely due to a restriction in the windows machine which is not allowing to execute the script. 无论如何,如果您仍然遇到此问题,建议您在Softlayer中以“硬件问题”为主题打开故障单,因为该问题很可能是由于Windows计算机中的限制而导致无法执行脚本。

Regards 问候

I believe the problem with PowerShell as a provisioning script is the default configuration of PowerShell requires a signed PowerShell script to execute (with no arguments defined). 我相信PowerShell作为配置脚本的问题是PowerShell的默认配置需要执行签名的PowerShell脚本(未定义任何参数)。 If the PowerShell script is not signed, the execution policy has to be changed on the server, or flags passed to the PowerShell interpreter to allow execution. 如果未对PowerShell脚本进行签名,则必须在服务器上更改执行策略,或者将标记传递给PowerShell解释器以允许执行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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