-1

I have some PowerShell scripts, which remotely collect some info form Windows machines via WMI and then return result in JSON format. Now, for these goal i have windows machine, which has all my scripts on it and has remote access to all my windows machines. All machines are domain machines. The goal is to move the functionality of PowerShell script execution to some linux OS based machine (Debian in prefer). Some example of PowerShell code:

$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

I saw some PowerShell stuff for Linux, but remote WMI calls is not working for them. I see a workaround to use Ansible for send scripts to machines and execute it localy, but Ansible needs WinRM support, which need to be set up on each of Windows machine firstly. What is the best practice for these stuff? Python solution in prefer

1
  • Use PowerShell Remoting using SSH. help about_Remote, help about_Remote_Requirements Commented Oct 21, 2024 at 18:35

1 Answer 1

2

The wmi cmdlets are not supported in Powershell 7.x, which is the multiplatform version.
Use the cim cmdlets insteads.

Sign up to request clarification or add additional context in comments.

1 Comment

cim cmdlets should connect from linux to remote windows machine as well as WMI. But CIM uses WinRM to do stuff like these which should be set up firstly. CIM is better and should be used instead of WMI, no argue, but it's not a solution for my question

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.