Skip to content

Instantly share code, notes, and snippets.

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
@MyITGuy
MyITGuy / Remove-WMIInvalidContent.ps1
Last active March 7, 2025 17:18
This script repairs the "The package data in WMI is not consistent to PkgLib" and "Package can't be found in PkgLib" errors in smsdpmon.log on Distribution Points by searching for packages that appear to be in de Content Library according to WMI but
<#
.Synopsis
Repairs the "The package data in WMI is not consistent to PkgLib" errors after ConfigMgr2012R2 upgrade
.DESCRIPTION
This script repairs the "The package data in WMI is not consistent to PkgLib" errors after ConfigMgr2012R2 upgrade by
searching for packages that appear to be in de Content Library according to WMI but are not there and do not exist anymore
This cleanup will run against all distribution points and when invalid WMI instances are found, they will be removed.
Detailed description of this issue: http://blogs.technet.com/b/configmgrteam/archive/2012/05/07/troubleshooting-content-mismatch-warnings-on-a-distribution-point-in-system-center-2012-configuration-manager.aspx?wa=wsignin1.0
Script is to be used at own risk
.EXAMPLE
function Get-Owner {
[CmdletBinding()]
PARAM(
[Parameter(Mandatory = $false, Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
[ValidateScript({
$Item = $_ | Get-Item
(Test-Path -Path $Item) -eq $true -and $Item.GetType().FullName -in @('System.IO.FileInfo', 'System.IO.DirectoryInfo')
})]
$Path
)
index=uscc_is_workstation_windows SourceName="Microsoft-Windows-DistributedCOM" EventCode=10028
| rex field=Message "computer (?<HostName>.*) using"
| rex field=Message "PID.*\((?<ProcessPath>.*)\)"
| rex field=Message "CLSID.*\{(?<CLSID>.*)\}"
| eval Component=case(
CLSID = "8BC3F05E-D86B-11D0-A075-00C04FB68820", "Windows Management and Instrumentation",
CLSID = "3C3A70A7-A468-49B9-8ADA-28E11FCCAD5D", "RAServer",
1 = 1, CLSID
)
```| regex Message="ab950015400007U|a01d753600000DQ|a0307881900001M"```
# Download and Install latest Production ring OneDriveSetup.exe installer for Windows
function Get-DownloadFileName {
[CmdletBinding()]
param(
[Uri]
$Uri
)
$Response = $null
# $ErrorActionPreference = 'SilentlyContinue'
if (!$Response) {
function Get-SplunkDownload {
[CmdletBinding()]
param(
[string[]]$Product
,
[string[]]$XProduct
,
[string[]]$Architecture
,
[string[]]$XArchitecture
We couldn’t find that file to show.
function Get-WsusSynchronizationHistory {
[CmdletBinding()]
param()
begin {
$IUpdateServer = [Microsoft.UpdateServices.Administration.AdminProxy]::GetUpdateServer()
$ISubscription = $IUpdateServer.GetSubscription()
$SynchronizationHistoryCollection = $ISubscription.GetSynchronizationHistory()
}
$CMContentUpdateServicesPackageInfo = Get-CMContentUpdateServicesPackageInfo
$CMContentUpdateServicesPackageInfo | Where-Object { $_.IsSuperseded -eq $true -and $_.IsDeployed -eq $false } | Select-Object -Property Path, FileName, FolderSizeFriendly, DateRevised
function Resolve-ContentIdToPackage {
[CmdletBinding()]
param(
[Alias('UID')]
[string[]]$ContentUniqueId
)
begin {
$SiteCode = (Get-CimInstance -ClassName SMS_Authority -Namespace root\ccm).Name.Split(':')[1]
$PreLocation = Get-Location