当前位置:网站首页 > 更多 > 玩电脑 > 正文

[玩转系统] 如何从 ConfigMgr 控制台启动 PowerShell

作者:精品下载站 日期:2024-12-14 12:11:53 浏览:14 分类:玩电脑

如何从 ConfigMgr 控制台启动 PowerShell


在本文中,您将了解如何从 ConfigMgr 控制台启动 PowerShell。从 SCCM 控制台连接到 PowerShell 后,您可以运行 ConfigMgr PowerShell cmdlet。

打开 PowerShell 会话的最简单方法是直接从 Configuration Manager 控制台,该控制台允许运行 cmdlet。 Configuration Manager PowerShell cmdlet 库在最新的当前分支版本上支持 PowerShell 7。

大多数人可能都知道可以使用 Windows PowerShell 来管理 Configuration Manager 层次结构。您可以使用 PowerShell 脚本来自动化或扩展 Configuration Manager。

您可以从 ConfigMgr 控制台或 Windows PowerShell 会话在 PowerShell 中运行配置管理器 cmdlet 和脚本。当您使用 Configuration Manager 控制台运行 cmdlet 时,您的会话会自动在站点上下文中运行。

请注意,从 SCCM 版本 2103 开始,Configuration Manager PowerShell 模块需要 Microsoft .NET 版本 4.7.2 或更高版本。在运行 ConfigMgr PowerShell cmdlet 之前,请确保 SCCM 服务器上的 .NET Framework 已更新到 4.7.2。

如何从 ConfigMgr 控制台启动 PowerShell

执行以下步骤从 SCCM 控制台启动 PowerShell:

  • 启动配置管理器控制台。
  • 左上角有一个蓝色矩形。选择蓝色矩形中的白色箭头,然后选择通过 Windows PowerShell 连接

[玩转系统] 如何从 ConfigMgr 控制台启动 PowerShell

Windows PowerShell 加载后,您将看到包含站点代码的提示。例如,如果站点代码为“MCM”,则提示符如下所示: PS MCM:> 这确认您已从 SCCM 控制台成功启动 PowerShell。

[玩转系统] 如何从 ConfigMgr 控制台启动 PowerShell

运行 Get-CMSite PowerShell 命令

要验证您是否已从 ConfigMgr 控制台成功连接到 PowerShell,请运行 Get-CMSite cmdlet。此 cmdlet 返回有关您当前连接到的 Configuration Manager 站点以及任何子站点的信息。例如,站点服务器名称、SCCM 内部版本号、安装目录、站点名称和版本。

SmsProviderObjectPath       : SMS_Site.SiteCode="MCM"
BuildNumber                 : 9096
ContentLibraryLocation      :
ContentLibraryMoveProgress  : 100
ContentLibraryStatus        : 3
Features                    : 0000000000000000000000000000000000000000000000000000000000000000
InstallDir                  : C:\Program Files\Microsoft Configuration Manager
Mode                        : 0
ReportingSiteCode           :
RequestedStatus             : 110
SecondarySiteCMUpdateStatus : 2
ServerName                  : corpcm.prajwal.local
SiteCode                    : MCM
SiteName                    : Microsoft Configuration Manager Primary Site
Status                      : 1
TimeZoneInfo                : FFFFFEB6 0000 0000 0000 0000 0000 0000 0000 0000 00000000 0000 0000 0000 0000 0000 0000
                              0000 0000 FFFFFFC4
Type                        : 2
Version                     : 5.00.9096.1000

[玩转系统] 如何从 ConfigMgr 控制台启动 PowerShell

注意:当您从 Configuration Manager 控制台启动 PowerShell 或 PowerShell ISE 时,它会对进程范围使用“AllSigned”执行策略。

导入配置管理器 PowerShell 模块

您可以通过手动加载配置管理器模块从现有 Windows PowerShell 会话连接到配置管理器。

  • 从“开始”菜单打开 Windows PowerShell 会话。
  • 使用 Import-Module ConfigurationManager cmdlet 导入配置管理器模块。

[玩转系统] 如何从 ConfigMgr 控制台启动 PowerShell

注意:从 ConfigMgr 版本 2111 开始,当您安装 Configuration Manager 控制台时,模块的路径现在会添加到系统环境变量 PSModulePath 中。

您需要 登录账户 后才能发表评论

取消回复欢迎 发表评论:

关灯