当我在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:有一个到主目录的虚拟映射。主目录存储在一个名为$home的变量中。
大多数PowerShell cmdlet都不能很好地与Azure:\alias配合使用。要克服这一点,只需键入:
cd $HOME
在主目录中之后,cmdlet将按照您编写的方式工作。