Last active
March 18, 2025 22:48
-
-
Save MyITGuy/20c9a35bc40f308f610ade03ce8afccc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Set-Location -Path "$(Get-PSDrive -PSProvider 'CMSite'):" | |
$CMSoftwareUpdateAutoDeploymentRules = Get-CMSoftwareUpdateAutoDeploymentRule -Fast | |
$CMSoftwareUpdateAutoDeploymentRuleDeployments = Get-CMSoftwareUpdateAutoDeploymentRuleDeployment | |
$CMSoftwareUpdateAutoDeploymentRuleDeployments | ForEach-Object { | |
$CMSoftwareUpdateAutoDeploymentRuleDeployment = $_ | |
$CMSoftwareUpdateAutoDeploymentRule = $CMSoftwareUpdateAutoDeploymentRules | Where-Object AutoDeploymentID -eq $CMSoftwareUpdateAutoDeploymentRuleDeployment.RuleID | |
$DeploymentSettings = ([xml]$CMSoftwareUpdateAutoDeploymentRuleDeployment.DeploymentTemplate).DeploymentCreationActionXML | ConvertTo-Csv -NoTypeInformation | ConvertFrom-Csv | Select-Object -Property * -ExcludeProperty xsd,xsi | |
$Evaluation = @() | |
$Evaluation += $DeploymentSettings.UseRemoteDP -eq $false | |
$Evaluation += $DeploymentSettings.UseUnprotectedDP -eq $false | |
$Evaluation += $DeploymentSettings.AllowWUMU -eq $true | |
$Evaluation += $DeploymentSettings.AllowUseMeteredNetwork -eq $true | |
$CMSoftwareUpdateAutoDeploymentRuleDeployment | Add-Member -MemberType NoteProperty -Name 'Realign' -Value ($Evaluation -contains $false) | |
$CMSoftwareUpdateAutoDeploymentRuleDeployment | Add-Member -MemberType NoteProperty -Name 'RuleName' -Value $CMSoftwareUpdateAutoDeploymentRule.Name | |
$CMSoftwareUpdateAutoDeploymentRuleDeployment | Add-Member -MemberType NoteProperty -Name 'NoInstallOnRemote' -Value $DeploymentSettings.UseRemoteDP | |
$CMSoftwareUpdateAutoDeploymentRuleDeployment | Add-Member -MemberType NoteProperty -Name 'NoInstallOnUnprotected' -Value $DeploymentSettings.UseUnprotectedDP | |
$CMSoftwareUpdateAutoDeploymentRuleDeployment | Add-Member -MemberType NoteProperty -Name 'AllowDownloadFromMicrosoftUpdate' -Value $DeploymentSettings.AllowWUMU | |
$CMSoftwareUpdateAutoDeploymentRuleDeployment | Add-Member -MemberType NoteProperty -Name 'AllowUseMeteredNetwork' -Value $DeploymentSettings.AllowUseMeteredNetwork | |
$CMSoftwareUpdateAutoDeploymentRuleDeployment | |
} | Select-Object -Property Realign, RuleName, CollectionName, NoInstallOnRemote, NoInstallOnUnprotected, AllowDownloadFromMicrosoftUpdate, AllowUseMeteredNetwork | Format-Table -AutoSize | |
# } | Where-Object Realign -eq $true | Set-CMSoftwareUpdateAutoDeploymentRuleDeployment -AllowDownloadFromMicrosoftUpdate $true -AllowUseMeteredNetwork $true -NoInstallOnRemote $true -NoInstallOnUnprotected $true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Get-CMSoftwareUpdateAutoDeploymentRuleDeployment | Set-CMSoftwareUpdateAutoDeploymentRuleDeployment -AllowDownloadFromMicrosoftUpdate $true -AllowUseMeteredNetwork $true -NoInstallOnRemote $true -NoInstallOnUnprotected $true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Get-CMSoftwareUpdateDeployment | Set-CMSoftwareUpdateDeployment -DownloadFromMicrosoftUpdate $true -AllowUseMeteredNetwork $true -ProtectedType NoInstall -UnprotectedType NoInstall |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Set-Location -Path "$(Get-PSDrive -PSProvider 'CMSite'):" | |
enum DP_LOCALITY { | |
DP_DOWNLOAD_FROM_LOCAL = 4 | |
DP_DOWNLOAD_FROM_REMOTE = 6 | |
DP_NO_FALLBACK_UNPROTECTED = 17 | |
DP_ALLOW_WUMU = 18 | |
DP_ALLOW_METERED_NETWORK = 19 | |
} | |
$CMApplicationDeployments = Get-CMApplicationDeployment | Sort-Object -Property ApplicationName | Select-Object -First 1 | |
$CMApplicationDeployments | ForEach-Object { | |
$CMApplicationDeployment = $_ | |
$DeploymentSettings = @{ | |
UseRemoteDP = ($CMApplicationDeployment.DPLocality -band [System.Math]::Pow(2, [DP_LOCALITY]::DP_DOWNLOAD_FROM_REMOTE.value__)) -eq ([System.Math]::Pow(2, [DP_LOCALITY]::DP_DOWNLOAD_FROM_REMOTE.value__)) | |
UseUnprotectedDP = -not ($CMApplicationDeployment.DPLocality -band [System.Math]::Pow(2, [DP_LOCALITY]::DP_NO_FALLBACK_UNPROTECTED.value__)) -eq ([System.Math]::Pow(2, [DP_LOCALITY]::DP_NO_FALLBACK_UNPROTECTED.value__)) | |
AllowWUMU = ($CMApplicationDeployment.DPLocality -band [System.Math]::Pow(2, [DP_LOCALITY]::DP_ALLOW_WUMU.value__)) -eq ([System.Math]::Pow(2, [DP_LOCALITY]::DP_ALLOW_WUMU.value__)) | |
AllowUseMeteredNetwork = ($CMApplicationDeployment.DPLocality -band [System.Math]::Pow(2, [DP_LOCALITY]::DP_ALLOW_METERED_NETWORK.value__)) -eq ([System.Math]::Pow(2, [DP_LOCALITY]::DP_ALLOW_METERED_NETWORK.value__)) | |
} | |
$Evaluation = @() | |
$Evaluation += $DeploymentSettings.UseRemoteDP -eq $false | |
$Evaluation += $DeploymentSettings.UseUnprotectedDP -eq $false | |
$Evaluation += $DeploymentSettings.AllowWUMU -eq $true | |
$Evaluation += $DeploymentSettings.AllowUseMeteredNetwork -eq $true | |
$CMApplicationDeployment | Add-Member -MemberType NoteProperty -Name 'Realign' -Value ($Evaluation -contains $false) | |
$CMApplicationDeployment | Add-Member -MemberType NoteProperty -Name 'NoInstallOnRemote' -Value $DeploymentSettings.UseRemoteDP | |
$CMApplicationDeployment | Add-Member -MemberType NoteProperty -Name 'NoInstallOnUnprotected' -Value $DeploymentSettings.UseUnprotectedDP | |
$CMApplicationDeployment | Add-Member -MemberType NoteProperty -Name 'AllowDownloadFromMicrosoftUpdate' -Value $DeploymentSettings.AllowWUMU | |
$CMApplicationDeployment | Add-Member -MemberType NoteProperty -Name 'AllowUseMeteredNetwork' -Value $DeploymentSettings.AllowUseMeteredNetwork | |
$CMApplicationDeployment | |
} | Select-Object -Property Realign, ApplicationName, CollectionName, NoInstallOnRemote, NoInstallOnUnprotected, AllowDownloadFromMicrosoftUpdate, AllowUseMeteredNetwork | Format-Table -AutoSize |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Set-Location -Path "$(Get-PSDrive -PSProvider 'CMSite'):" | |
enum DP_LOCALITY { | |
DP_DOWNLOAD_FROM_LOCAL = 4 | |
DP_DOWNLOAD_FROM_REMOTE = 6 | |
DP_NO_FALLBACK_UNPROTECTED = 17 | |
DP_ALLOW_WUMU = 18 | |
DP_ALLOW_METERED_NETWORK = 19 | |
} | |
$CMSoftwareUpdateDeployments = Get-CMSoftwareUpdateDeployment | Sort-Object -Property AssignmentName | |
$CMSoftwareUpdateDeployments | ForEach-Object { | |
$CMSoftwareUpdateDeployment = $_ | |
$TargetCollection = Get-CMCollection -Id $CMSoftwareUpdateDeployment.TargetCollectionID | |
$DeploymentSettings = @{ | |
UseRemoteDP = ($CMSoftwareUpdateDeployment.DPLocality -band [System.Math]::Pow(2, [DP_LOCALITY]::DP_DOWNLOAD_FROM_REMOTE.value__)) -eq ([System.Math]::Pow(2, [DP_LOCALITY]::DP_DOWNLOAD_FROM_REMOTE.value__)) | |
UseUnprotectedDP = -not ($CMSoftwareUpdateDeployment.DPLocality -band [System.Math]::Pow(2, [DP_LOCALITY]::DP_NO_FALLBACK_UNPROTECTED.value__)) -eq ([System.Math]::Pow(2, [DP_LOCALITY]::DP_NO_FALLBACK_UNPROTECTED.value__)) | |
AllowWUMU = ($CMSoftwareUpdateDeployment.DPLocality -band [System.Math]::Pow(2, [DP_LOCALITY]::DP_ALLOW_WUMU.value__)) -eq ([System.Math]::Pow(2, [DP_LOCALITY]::DP_ALLOW_WUMU.value__)) | |
AllowUseMeteredNetwork = ($CMSoftwareUpdateDeployment.DPLocality -band [System.Math]::Pow(2, [DP_LOCALITY]::DP_ALLOW_METERED_NETWORK.value__)) -eq ([System.Math]::Pow(2, [DP_LOCALITY]::DP_ALLOW_METERED_NETWORK.value__)) | |
} | |
$Evaluation = @() | |
$Evaluation += $DeploymentSettings.UseRemoteDP -eq $false | |
$Evaluation += $DeploymentSettings.UseUnprotectedDP -eq $false | |
$Evaluation += $DeploymentSettings.AllowWUMU -eq $true | |
$Evaluation += $DeploymentSettings.AllowUseMeteredNetwork -eq $true | |
$CMSoftwareUpdateDeployment | Add-Member -MemberType NoteProperty -Name 'Realign' -Value ($Evaluation -contains $false) | |
$CMSoftwareUpdateDeployment | Add-Member -MemberType NoteProperty -Name 'SoftwareUpdateName' -Value $CMSoftwareUpdateDeployment.AssignmentName | |
$CMSoftwareUpdateDeployment | Add-Member -MemberType NoteProperty -Name 'CollectionName' -Value $TargetCollection.Name | |
$CMSoftwareUpdateDeployment | Add-Member -MemberType NoteProperty -Name 'NoInstallOnRemote' -Value $DeploymentSettings.UseRemoteDP | |
$CMSoftwareUpdateDeployment | Add-Member -MemberType NoteProperty -Name 'NoInstallOnUnprotected' -Value $DeploymentSettings.UseUnprotectedDP | |
$CMSoftwareUpdateDeployment | Add-Member -MemberType NoteProperty -Name 'AllowDownloadFromMicrosoftUpdate' -Value $DeploymentSettings.AllowWUMU | |
$CMSoftwareUpdateDeployment | Add-Member -MemberType NoteProperty -Name 'AllowUseMeteredNetwork' -Value $DeploymentSettings.AllowUseMeteredNetwork | |
$CMSoftwareUpdateDeployment | |
} | Select-Object -Property Realign, SoftwareUpdateName, CollectionName, NoInstallOnRemote, NoInstallOnUnprotected, AllowDownloadFromMicrosoftUpdate, AllowUseMeteredNetwork | Format-Table -AutoSize | |
# } | Where-Object Realign -eq $true | Set-CMSoftwareUpdateDeployment -DownloadFromMicrosoftUpdate $true -AllowUseMeteredNetwork $true -ProtectedType NoInstall -UnprotectedType NoInstall |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment