从 Linux 计算机运行 Powershell 脚本

问题描述 投票:0回答:1

我有一些PowerShell脚本,它们通过WMI从Windows机器远程收集一些信息,然后以JSON格式返回结果。现在,为了实现这些目标,我拥有 Windows 机器,它上面有我的所有脚本,并且可以远程访问我的所有 Windows 机器。所有机器都是域机器。目标是将 PowerShell 脚本执行的功能转移到某些基于 Linux 操作系统的计算机(首选 Debian)。 PowerShell 代码的一些示例:

$User = "User"
$Password = "VerySecurePassword"
$Computer = "192.168.0.101"

$s_password = $password | ConvertTo-SecureString -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential($user, $s_password)

get-wmiobject Win32_Product -Computer $Computer -Credential $Cred | Sort Name

我看到了一些适用于 Linux 的 PowerShell 东西,但远程 WMI 调用对它们不起作用。我看到了一种使用 Ansible 将脚本发送到计算机并在本地执行的解决方法,但 Ansible 需要 WinRM 支持,需要首先在每台 Windows 计算机上进行设置。这些东西的最佳实践是什么? Preferred 中的 Python 解决方案

linux powershell powershell-remoting
1个回答
1
投票

Powershell 7.x(多平台版本)不支持

wmi
cmdlet。
请改用
cim
cmdlet。

© www.soinside.com 2019 - 2024. All rights reserved.