使用Microsoft SCMM 2012 SP1中的Powershell或WMI更新应用程序中的内容

在右键单击应用程序部署types时,我们可以select更新内容。 有没有办法使用Powershell或WMI方法做这个动作?

我目前正在使用这个PowerShell脚本更新所有应用程序的内容,只有警告,修订总是增加:

try { Get-Wmiobject -Namespace "root\SMS\Site_<sitecode>" -Class SMS_Application -Filter "isLatest='true' and isExpired='false'" | foreach{ $name = $_.LocalizedDisplayName echo "Application : $name" $dptypes = Get-CMDeploymentType -ApplicationName "$name" foreach ($dpt in $dptypes){ $dptname = $dpt.LocalizedDisplayName echo "Deployment Type: $dptname" Update-CMDistributionPoint -ApplicationName "$name" -DeploymentTypeName "$dptname" } } } catch { $_.Exception.Message } 

Set-CMDeploymentType与-ContentLocation将强制更新,即使ContentLocation设置为与原始相同。

我的代码如下所示:

 $app = Get-CMApplication -Name $PackageName $depType = $app | Get-CMDeploymentType $depType | Set-CMDeploymentType -MsiOrScriptInstaller -ProductCode $productCode -ContentLocation $PkgRead 

现有的位置可能会更难以确定 – 如果您不知道它在哪里,可以将其从部署typesXML或WMI中提取出来。

经过一番深入的search,我find了一个解 在SCCM SDK中有一个名为SMS_ContentPackage的WMI类,它具有公共方法Commit()。 使用这个,我能够更新所有应用程序的内容,在服务器上使用以下Powershell代码:

 foreach($application in Get-CMApplication){ $Get_WmiObject = @{ 'Namespace' = 'root\SMS\Site_<SiteCode>'; 'Class' = 'SMS_ContentPackage'; 'Filter' = "PackageID='$($application.PackageId)'"; } (Get-Wmiobject @Get_WmiObject).Commit() | Out-null }