Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

saving to WMI fails

$
0
0

Hi folks. i'm trying to make a change to a WMI table but it seems to not save. Can someone please give me insight to what is going wrong? I suspect it has to do with the line that is in bold below. Thanks a bunch

 

$SiteServer = "server1234.site.com"

$SiteCode = "ABC"

$AppName = "WinZip"

 

try {

    Add-Type -Path (Join-Path -Path (Get-Item $env:SMS_ADMIN_UI_PATH).Parent.FullName -ChildPath "Microsoft.ConfigurationManagement.ApplicationManagement.dll")

    Add-Type -Path (Join-Path -Path (Get-Item $env:SMS_ADMIN_UI_PATH).Parent.FullName -ChildPath "Microsoft.ConfigurationManagement.ApplicationManagement.Extender.dll")

    Add-Type -Path (Join-Path -Path (Get-Item $env:SMS_ADMIN_UI_PATH).Parent.FullName -ChildPath "Microsoft.ConfigurationManagement.ApplicationManagement.MsiInstaller.dll")

}

catch {

    Write-Error $_.Exception.Message

}

 

$Applications = Get-WmiObject -Namespace "root\SMS\site_ABC" -Class "SMS_ApplicationLatest" -ComputerName server1234.site.com -Filter "LocalizedDisplayName like 'WinZip'"

foreach ($Application in $Applications) {

    $LocalizedDisplayName = $Application.LocalizedDisplayName

    $CurrentApplication = [wmi]$Application.__PATH

    $ApplicationXML = [Microsoft.ConfigurationManagement.ApplicationManagement.Serialization.SccmSerializer]::DeserializeFromString($CurrentApplication.SDMPackageXML, $true)

    foreach ($DeploymentType in $ApplicationXML.DeploymentTypes) {

        $DeploymentType.Installer.EnhancedDetectionMethod.Rule.Expression.Operands[1].Value = "7.1.1.9" 

 

        # Re-serialize the ApplicationXML object

        $UpdatedXML = [Microsoft.ConfigurationManagement.ApplicationManagement.Serialization.SccmSerializer]::SerializeToString($ApplicationXML, $true)

        # Update WMI object

        $CurrentApplication.SDMPackageXML = $UpdatedXML

        $CurrentApplication.Put()

    }

}


Viewing all articles
Browse latest Browse all 6937

Trending Articles