APM_PowerShell TrustedHosts作用(用法)

APM_PowerShell TrustedHosts作用(用法)

当我们需要在AppManager中添加PowerShell监控时,我们需要将对应的APM设备添加到TrustedHosts中,否则无法执行PowerShell脚本。

并且TrustedHosts可以限制在设备上执行脚本的主机。

查看TrustedHosts列表的计算机:

Get-Item WSMan:\localhost\Client\TrustedHosts

将所有的计算机添加到TrustedHosts列表:

Set-Item WSMan:\localhost\Client\TrustedHosts -Value *

将特定计算机添加到 TrustedHosts 列表:

您可以使用以下命令添加基于主机名选择的特定计算机,方法是用逗号 (,) 分隔它们,其中 ComputerName 可以采用 Server01 或 Server01.yourdomain.com 格式。

Set-Item WSMan:\localhost\Client\TrustedHosts -Value <ComputerName>,[<ComputerName>]

将计算机添加到 TrustedHosts 的现有列表:

如果已将某些计算机添加到 TrustedHosts 列表中,并且想要添加其他计算机,而不删除以前的条目,则应使用以下方法。这是因为 TrustedHosts 列表会根据您运行的最后一个 Set-Item 命令进行更新,从而覆盖以前的条目。

使用以下命令将当前 TrustedHosts 计算机列表保存到 curList 变量。

$curList = (Get-Item WSMan:\localhost\Client\TrustedHosts).value

若要将计算机添加到当前列表,请通过指定您创建的变量和要添加的计算机名称来键入以下命令。

Set-Item WSMan:\localhost\Client\TrustedHosts -Value "$curList, Server01"

或者,若要避免使用变量,请将 -Concatenate 开关添加到 Set-Item 命令中,以添加新条目和以前的条目。例如:

Set-Item WSMan:\localhost\Client\TrustedHosts -Concatenate -Value Server02

使用 IP 地址将计算机添加到 TrustedHosts 列表:

与前面的命令类似,您可以使用 IPv4 或 IPv6 地址。对于 IPv6,您必须键入 [] 之间的地址。

Set-Item WSMan:\localhost\Client\TrustedHosts -Value 10.10.10.1,[0:0:0:0:0:0:0:0]


    • Related Articles

    • APM数据收集需要Powershell版本4或更高版本

      低于powershell版本4不支持Applications Manager用于数据收集的某些cmdlet。 例如用于端点连接检查的“Test-NetConnection”cmdlet在旧版本powershell中不可用。 请升级到更高版本的Powershell来查看丢失的数据。
    • Microsoft Azure VM (Windows) - Powershell远程失败

      要解决此问题,请按照以下步骤操作: 转到监视器操作 -> 编辑监视器页面并检查是否启用了启用用户操作系统监控选项。验证用户名和密码是否正确。 验证是否按照以下链接中的说明完成了所有先决条件: https://www.manageengine.cn/products/applications_manager/help/prerequisites-for-applications-manager.html#azurevmGuestOS 尝试运行PowerShell脚本并按照以下步骤获取输出: ...
    • 无法安装Microsoft 365 powershell模块

      当您尝试使用Install-Module -Name MSOnline 命令安装MSOnline模块时,如果出现类似"无法下载可用供应商列表。请检查您的Internet 连接 "的错误,可能是由于任何 以下原因: 无法访问Internet:检查Applications Manager安装的服务器中是否有正确的Internet连接。 TLS 1.2不存在: 检查可用的TSL版本,请在管理PowerShell窗口中执行以下命令:  ...
    • 错误:未安装Exchange Online Management Powershell模块

      当在Exchange Online编辑监视器页面中启用了使用Exchange Online PowerShell V2模块复选框,但Exchange Online Management PowerShell模块不存在时,会发生此错误。 在安装了AppManager服务器中,以管理员权限在Powershell窗口中运行以下命令,并检查是否列出了ExchangeOnlineManagement模块。 Get-Module -ListAvailable 如果该模块不存在,请从以下链接安装该模块。 ...
    • Microsoft Azure - 错误:未安装Az Powershell模块

      在添加Microsoft Azure监视器时或在数据收集过程中,如果出现此错误,请按照以下步骤进行故障排除: 检查以下链接中提到的所有先决条件是否已完成: https ://www.manageengine.cn/products/applications_manager/help/prerequisites-for-applications-manager.html#mode2 打开admin Powershell窗口并运行以下命令来检查已安装模块的列表: Get-Module ...