azure-cloud-shell - Azure Cloud Shell 运行 ps1 脚本时出现问题
问题描述
在我们的 Azure Cloud Shell、Powershell 模式下,我们无法运行 ps1 文件。尽管我们在 MS Doc 中做同样的事情。任何建议,我做错了什么。
PS Azure:\> dir
Directory: Azure:/Shared PAAS – Test/StorageAccounts/tstoweuyptobi/Files/azureshellfiles/goal0402preprod/powershell
Mode Name
---- ----
. Build_goal.ps1
. Test goal_Files.ps1
. test.ps1
Azure:/Shared PAAS – Test/StorageAccounts/tstoweuyptobi/Files/azureshellfiles/goal0402preprod/powershell
PS Azure:\> ./test.ps1
./test.ps1 : The term './test.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:1
+ ./test.ps1
+ ~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (./test.ps1:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Azure:/Shared PAAS – Test/StorageAccounts/tstoweuyptobi/Files/azureshellfiles/goal0402preprod/powershell
PS Azure:\>
解决方案
下面的示例来自Microsoft Docs。诀窍是在保存脚本的位置打开外壳。这仅在您的脚本不使用存储在本地设备上的库时才有效。您可能还需要导入所需的任何模块,例如 AzureAD
# change to your cloud drive fileshare
cd $HOME\clouddrive
# run the script
.\helloworld.ps1
Hello World!
推荐阅读
- unix - x86 线程上下文切换:为什么需要将程序计数器存储到 TCB 中?
- c# - NuGet do I need to install Microsoft.EntityFrameworkCore if all I need is its provider?
- python - 有没有更简洁的方法来在 Python 中定义这个函数值数组?
- c - 我的用户输入不是乘以我的存储值
- revit-api - 包括/排除链接模型的可见性图形
- sharepoint - 不确定在哪里处理 Sharepoint SPWeb 和 SpSite
- ios - 自定义表格视图标题的左上角和右上角
- webpack - 如何使 Favicons Webpack 插件不向资产目录添加初始斜杠
- mysql - 相当于 HQL 中的 GREATEST()
- python-3.x - 为什么 PyODBC 认为我的 SQL 只有 1 个参数