PowerShell Az模块:离线导出和导入 [英] PowerShell Az module: export and import offline

查看:85
本文介绍了PowerShell Az模块:离线导出和导入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将PowerShell Az模块从一台计算机移动到另一台脱机(两台计算机具有相同的窗口(10 Pro 1809)、. net,powershell(5.1)等版本)

I need to move PowerShell Az module from one machine to another offline (both machines have the same windows (10 Pro 1809), .net, powershell (5.1), etc versions)

我不能使用Private PowerShellGet存储库或MSI安装程序

I can't use either Private PowerShellGet Repositories or MSI installer

我在上运行 Save-Module -Name Az -Path'C:\ Users \ kag \ Documents \ ps_modules'-RequiredVersion 3.7.0 -Force 机器,它给了我50多个dirs出口:

I run Save-Module -Name Az -Path 'C:\Users\kag\Documents\ps_modules' -RequiredVersion 3.7.0 -Force on "donor" machine and it gives me 50+ dirs exported:

我将所有内容复制到接收者"机器并正在运行:

I copy all to "receiver" machine and running:

Get-ChildItem "C:\Users\kag\Documents\ps_modules\*" -Recurse | Unblock-File
Import-Module -name "C:\Users\kag\Documents\ps_modules\Az" -Verbose

..但是所有依赖项都出错:

..but getting errors for all dependencies:

有什么想法如何正确地使Az模块脱机?

Any ideas how to correctly move Az module offline?

推荐答案

以下是我的评论作为答案:

Here my comments as answer:

看来,您将模块保存在 C:\ Users \ kag \ Documents \ ps_modules 中的路径不是PowerShell知道的模块路径之一.

It seems the path you saved the module in C:\Users\kag\Documents\ps_modules is not one of the module paths PowerShell knows of.

您可以通过键入以下内容来测试PowerShell使用哪些路径来找到您的模块

You can test which paths are used by PowerShell to find your modules by typing

$env:PSModulePath.split(';')

在控制台中.

以下摘录自 Stefan Stranger的博客

您可以添加仅适用于当前会话的临时路径:

You can add a temporary path that is available for the current session only:

$env:PSModulePath = $env:PSModulePath + ";C:\Users\kag\Documents\ps_modules"

要使其永久存在,您可以将以上行添加到PowerShell配置文件中,或手动将其添加到注册表中:

To make that permanent, you can either add the line above to your PowerShell profile, or manually add it to the registry:

$CurrentValue = [Environment]::GetEnvironmentVariable("PSModulePath", "User")
[Environment]::SetEnvironmentVariable("PSModulePath", $CurrentValue + ";C:\Users\kag\Documents\ps_modules", "User")

使用用户"仅将此路径存储为当前用户.使用机器"为所有用户提供该路径

这篇关于PowerShell Az模块:离线导出和导入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆