这不是 Powershell 代码问题,这是我们在此提供帮助的原因。您的问题是环境问题,因此确实应该将其移至 SuperUser 或 StackExchange。
然而,既然你在这里,这是环境问题,因为你可能没有正确/完整地设置它,如何设置和使用它在 MS Docs、MSDN 和遍布全球的许多其他位置都有完整的记录网。快速搜索,比如使用'AzureRM osx' 会显示如下内容。这些:
PowerShell, Azure and macOS? Absolutely!
使用 macOS 上的 Azure CLI,您可以做一些有趣的事情,例如
配置新的虚拟机或获取它们的状态概览。但是 Azure CLI
不是 PowerShell,因此它缺少一些我非常欣赏的功能。
为了能够通过以下方式管理 Azure,需要执行几个步骤
Mac 上的 PowerShell:
Install PowerShell
Install .NET Core
Install the AzureRm.NetCore.Preview module
brew update
brew install openssl
ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/
ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/
之后,您可以下载 .NET Core 的官方安装程序
苹果系统。安装后,您需要初始化一些代码。你可以做
通过使用以下命令:
mkdir hwapp
cd hwapp
dotnet new
dotnet restore
dotnet run
Install-Package -Name AzureRM.NetCore.Preview -Source https://www.powershellgallery.com/api/v2 -ProviderName NuGet -ExcludeVersion -Destination /usr/local/microsoft/powershell/6.0.0-alpha.11/Modules
get-module -listAvailable
AzureRM PowerShell Mac OS X
一切都可以通过从这里安装 AzureRM 来解决:
Install-Package -Name AzureRM.NetCore.Preview -Source https://www.powershellgallery.com/api/v2/ -ProviderName NuGet -ExcludeVersion -Destination $home/powershell/modules
Import-Module $home/powershell/modules/AzureRM.Profile.NetCore.Preview
Import-Module $home/powershell/modules/AzureRM.Resources.NetCore.Preview
Import-Module $home/powershell/modules/AzureRM.NetCore.Preview
Login-AzureRmAccount
附言。每次重新启动 PowerShell 时都必须重新运行 Import-Module。
Powershell and Azure on MacOS
好吧,除非你把它放在你的个人资料中。