azure - “运行 PowerShell”工件未能安装 CommandNotFoundException
问题描述
我正在尝试使用Azure 开发测试实验室中现有 VM 上的Run Powershell工件下载并运行 PowerShell 脚本(从 blob 存储)。
我收到以下错误,我认为我在做一些愚蠢的事情。
& : The term './script.ps1' is not recognized as the name of a cmdlet,
function, script file, or operable program. Check the spelling of the name, or
if a path was included, verify that the path is correct and try again.
At line:1 char:3
+ & ./script.ps1
+ ~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (./script.ps1:String) [], Comman
dNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
这是我的设置...
我还尝试了 JSON 数组语法,它给出了相同的结果,以及一个无效的 URL,它给出了 404 错误,所以看起来好像它正在下载我的脚本,但后来找不到它。
解决方案
以下是我前一阵子写的信息。需要注意的几点:
- 在撰写本文时,不支持文件夹结构。因此,脚本需要在容器的根目录下
- 确保您的 blob 是公开的
首先,您需要将文件保存在 Azure 存储中。在您的容器中上传后,单击该文件以访问其属性并复制 URL 字段。
例如,我创建了以下 Run.ps1 脚本文件并将其作为 blob 上传到存储:
param ( [string]$drive = "c:\" )
param ( [string]$folderName = "DefaultFolderName" )
New-Item -Path $drive -Name $folderName -ItemType "directory"
现在,在将“运行 PowerShell”工件添加到 VM 时,我们提供以下信息:
文件 URI(s):从前面的步骤复制的 URL 字段。(例如https://myblob.blob.core.windows.net/mycontainer/Run.ps1)
要运行的脚本: PS1 脚本的名称,(例如 Run.ps1)
脚本参数:在命令末尾编写的参数(例如 -drive "d:\" -folderName "MyFolder")
推荐阅读
- python - Tensorflow 没有“核心”属性
- excel - 根据单元格值将 pandas DataFrame 导出到 excel 中
- c - 通过信号 SIGQUIT 唤醒休眠的守护进程
- c++ - 如何在 MacOS Objective C / C++ 中将 UUID 转换为 16 字节 UInt8 数组
- python - 循环遍历Python中不同文件夹中的文件
- sql - SQL Server 2016 上的代码发生了奇怪的事情
- reactjs - 反应路由器得到哪个`
` 是活跃的吗? - javascript - Chrome 和 Firefox 之间的日期差异
- docker - Namenode 无法从 Docker 容器外部访问
- azure - No package Az found