运行PS1脚本的Azure Cloud Shell故障

时间:2018-09-07 21:26:35

标签: azure-cloud-shell

在我们的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:\>

2 个答案:

答案 0 :(得分:5)

下面的示例来自Microsoft Docs。 诀窍是要在保存脚本的位置打开外壳。 仅当您的脚本不使用本地设备上存储的库时,此方法才有效。您可能还需要导入所需的任何模块,例如AzureAD

# change to your cloud drive fileshare
cd $HOME\clouddrive

# run the script
.\helloworld.ps1

Hello World!

答案 1 :(得分:0)

Cloud Shell的默认目录似乎不允许脚本运行。将脚本复制到“ $ HOME \ clouddrive”,更改为该目录,然后从那里运行它。