Jump to content

Help translating powershell script to auto wmi Get-WmiObject


tfernandez
 Share

Recommended Posts

Hello, I'm beginner with Autoit, pls could you help me translating this powershell code to autoit.

$SiteCode='A01'
$SiteServer='SCCMServer'
$DPGroup="Dps"
$PackageID="A0100001"
        
        $DPGroupQuery = Get-WmiObject -Namespace "Root\SMS\Site_$SiteCode" -Class SMS_DistributionPointGroup -ComputerName $SiteServer `
        -ErrorAction STOP -Filter "Name='$DPGroup'"
        $DPGroupQuery.RemovePackages($PackageID)

I've tried with

$objWMI = ObjGet("winmgmts:\\"&$sccm_server_cm12&"\root\SMS\"&$sccmsiteid_cm12&"")
$objItems = $objWMI.ExecQuery("Select * From SMS_DistributionPointGroup WHERE name='" & $dpgroup & "'")

 If IsObj($objItems) Then

For $dpgroup In $objItems

ConsoleWrite($PackageID&@CRLF)
ConsoleWrite($dpgroup.name&@CRLF)
$dpgroup.RemovePackages($dpgroup)

next

Consolewrite works properly showing the name of the group, but the action to remove package from dp end with an COM error.

Thanks a lot.

Edited by tfernandez
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...