我正在尝试在 Windows 8.1 上使用 Windows Azure PowerShell 模块。我已经下载并安装了 Azure 模块,一开始我可以运行和使用“Windows Azure PowerShell”,它是一个只加载 Azure 的 PS。当我只打开一个普通的 PS 窗口并执行 Import-Module Azure 时,它会失败:
import-module : The specified module 'Azure' was not loaded because no valid module file was found in any module directory.
Run Code Online (Sandbox Code Playgroud)
我怀疑它与 powershell 版本或 64\32 位版本有关。
任何人都有这方面的经验?
Mat*_*sen 19
Windows Azure SDK 二进制文件和相关的 PowerShell cmdlet 都是 32 位的,这就是“Windows Azure Powershell”快捷方式总是启动 32 位 shell 的原因。
您可以通过引用模块清单的文件系统路径将 Azure 模块导入现有的 PowerShell 会话:
Import-Module "C:\Program Files (x86)\Microsoft SDKs\Windows Azure\PowerShell\Azure\Azure.psd1"
Run Code Online (Sandbox Code Playgroud)
[更新] 在最新的 Azure 中,使用
Import-Module "C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\ServiceManagement\Azure\Azure.psd1"
Run Code Online (Sandbox Code Playgroud)
要仅通过名称访问模块,您需要将其位置包含在PSModulePath
环境变量中(这里是对开发人员来说极其详细的细节):
$oldPSModulePath = [Environment]::GetEnvironmentVariable("PSModulePath")
$azureModulePath = "C:\Program Files (x86)\Microsoft SDKs\Windows Azure\PowerShell\"
$newPSModulePath = $oldPSModulePath,$azureModulePath -join ";"
[Environment]::SetEnvironmentVariable("PSModulePath",$newPSModulePath)
Run Code Online (Sandbox Code Playgroud)
以及你的 powershell 的速记表达式
$env:PSModulePath += ";C:\Program Files (x86)\Microsoft SDKs\Windows Azure\PowerShell\"
Import-Module Azure # <-- Now you can do this!
Run Code Online (Sandbox Code Playgroud)
您可以在 PowerShell 配置文件中包含上述内容
归档时间: |
|
查看次数: |
51847 次 |
最近记录: |