【问题标题】:Why can I create new files and directories in Azure Cloud Shell Bash, but not PowerShell?为什么我可以在 Azure Cloud Shell Bash 中创建新文件和目录,但不能在 PowerShell 中创建?
【发布时间】:2019-10-28 14:19:06
【问题描述】:

当我在 Azure Cloud Shell 中打开 Bash 时,我能够创建和编辑新文件和目录。

但是当我尝试在 Azure Cloud Shell 的 PowerShell 版本中执行此操作时,我无法执行任何这些操作。

例如,当我尝试创建一个新文件时:

Azure:/
PS Azure:\> new-item -Type file -Path my_new_files.txt
new-item : The node at path 'AzurePSDrive#Azure/my_new_files.txt' does not support the cmdlet 'New-Item'
At line:1 char:1
+ new-item -Type file -Path my_new_files.txt
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : NotImplemented: (AzurePSDrive#Azure/my_new_files.txt:String) [New-Item], NodeDoesNotSupportCmdletException
+ FullyQualifiedErrorId : NewItem.NotSupported,Microsoft.PowerShell.Commands.NewItemCommand

当我尝试 cd 进入我已经从 Bash shell 创建的目录时:

Azure:/
PS Azure:\> ls
clouddrive  jjj  jjj.txt
Azure:/
PS Azure:\> cd jjj
cd : Cannot find path 'Azure:/jjj' because it does not exist.
At line:1 char:1
+ cd jjj
+ ~~~~~~
+ CategoryInfo          : ObjectNotFound: (Azure:/jjj:String) [Set-Location], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.SetLocationCommand

为什么我可以在 Bash 中 mkdir、touch、cd 和 vi,但似乎没有文件/目录命令在 PowerShell 中有效?

【问题讨论】:

    标签: azure


    【解决方案1】:

    这是一个已知问题。 Azure: 具有到您的主目录的虚拟映射。主目录存储在一个名为 $HOME 的变量中。

    大多数 PowerShell cmdlet 不能很好地与 Azure:\ 别名配合使用。要克服这个问题,只需键入:

    cd $HOME

    进入主目录后,您的 cmdlet 将按照您编写的方式运行。

    【讨论】:

      猜你喜欢
      • 2020-07-25
      • 1970-01-01
      • 2015-01-25
      • 1970-01-01
      • 1970-01-01
      • 2012-11-22
      • 2014-09-13
      • 2021-09-05
      • 1970-01-01
      相关资源
      最近更新 更多