Skip to content

Instantly share code, notes, and snippets.

View CodyMathis123's full-sized avatar
🦖
Working from home

Cody Mathis CodyMathis123

🦖
Working from home
View GitHub Profile
DECLARE @allDPgroupID uniqueidentifier = (SELECT TOP 1 GroupID FROM v_SMS_DistributionPointGroup ORDER BY membercount DESC)
DECLARE @allDPgroupMemberCount int = (SELECT TOP 1 MemberCount FROM v_SMS_DistributionPointGroup ORDER BY membercount DESC)
SELECT DISTINCT dpgp.PkgID
, p.packagetype
, bycount.TargeteddDPCount
FROM v_DPGroupPackages dpgp
JOIN v_package p ON p.packageid = dpgp.PkgID
JOIN (
SELECT cdss.pkgid
@CodyMathis123
CodyMathis123 / SystemInfo-JSON.ps1
Created September 3, 2021 15:14
SystemInfo-JSON
$props = @('Name', 'Model', 'Manufacturer', 'Username', 'SystemSKUNumber', 'TotalPhysicalMemory')
$calculatedProps = @{ Name = 'RAM (GB)'; Expression = { [int]($_.TotalPhysicalMemory / 1GB) } }, @{ Name = 'Processor Name'; Expression = { (Get-CimInstance -Query 'SELECT Name FROM Win32_Processor').Name.Trim() } }
$fullPropsToSelect = foreach ($propToSelect in $($props, $calculatedProps)) {
$propToSelect
}
Get-CimInstance -Query "SELECT $($props -Join ',') FROM Win32_ComputerSystem" | Select-Object -Property $fullPropsToSelect -ExcludeProperty TotalPhysicalMemory | ConvertTo-Json
--Originally Written by: Narayana Vyas Kondreddi
--Modified By: Jon Mattivi
--Purpose: Search all tables and columns in the Orchestrator database to find variable instances
DECLARE @VarName nvarchar(100), @VarID nvarchar(100)
SET @VarName = 'MyVariableName'
SET @VarID = (Select VARIABLES.UniqueID
From VARIABLES
INNER JOIN OBJECTS ON OBJECTS.UniqueID = VARIABLES.UniqueID
<#
.SYNOPSIS
Searches the local WSUS for all PMPC updates and marks them as IsLocallyPublished = 0 in the SUSDB
.DESCRIPTION
This script is used to force all PMPC updates to show in the WSUS console. This is useful when you are in a WSUS
standalone scenarion and will not be managing updates through ConfigMgr or some other method.
By default, third party updates do not show in WSUS. This is a workound. Use at your own risk as it is a database edit.
.EXAMPLE
C:\PS> Set-PMPCUpdatesToShowInWSUS.ps1
@CodyMathis123
CodyMathis123 / Undecline-AllDeclineWSUSUpdates.ps1
Created February 15, 2023 17:13
Undecline ALL currently declined WSUS updates....
$wsus = Get-WsusServer
$scope = [Microsoft.UpdateServices.Administration.UpdateScope]::new()
$scope.ApprovedStates = [Microsoft.UpdateServices.Administration.ApprovedStates]::Declined
$updates = $wsus.GetUpdates($scope)
$AllComputersTargetGroup = $wsus.GetComputerTargetGroup([Microsoft.UpdateServices.Administration.ComputerTargetGroupId]::AllComputers)
foreach($computerGroup in $AllComputersTargetGroup.GetChildTargetGroups()){
foreach($update in $updates){
$update.Approve([Microsoft.UpdateServices.Administration.UpdateApprovalAction]::NotApproved, $computerGroup)
}
}