Skip to content

Instantly share code, notes, and snippets.

Avatar
🦖
Working from home

Cody Mathis CodyMathis123

🦖
Working from home
View GitHub Profile
View New-CCMScheduleStartTime.ps1
Function New-CCMScheduleStartTime {
[CmdletBinding()]
<#
.SYNOPSIS
Recreate a CMSchedule object with a new start time
.DESCRIPTION
Natively, the CMSchedule objects do not allow you to write to the StartTime property. This makes it
difficult to adjust the start time of an existing maintenance window. This function can be used to
'recreate' a CMSchedule based on the input schedule, with a new start time.
.PARAMETER CMSchedule
View PSADT-WaaS-InteractiveStart-CachedSnippet.ps1
<#
This snippet is for use in a PSADT script. It assumes you have added parameters, or hardcoded the following
* $DeploymentID - The deployment ID of the task sequence you want to check the cache for, and which will be invoked
* $CheckAC - A boolean (or switch) that determines if you want to force the user to plug in prior to upgrading. This step is only check if
the pre-caching has passed
#>
#region Validate that all content is pre-cached so we do not bother the user until the TS is ready to start
$TS = Get-WmiObject -Namespace ROOT\ccm\Policy\Machine\ActualConfig -Class CCM_SoftwareDistribution -Filter "ADV_AdvertisementID='$DeploymentID'" -Property PKG_PackageID, PKG_Name
if ($null -ne $TS) {
View Set-ContentNoSSL.ps1
#region detection
$SitePath = 'WSUS Administration/Content'
$getWebConfigurationPropertySplat = @{
Filter = '/system.webServer/security/Access'
Name = 'sslFlags'
PSPath = 'MACHINE/WEBROOT/APPHOST'
Location = $SitePath
}
try {
View Set-ApiRemoting30SSL.ps1
#region detection
$SitePath = 'WSUS Administration/ApiRemoting30'
$getWebConfigurationPropertySplat = @{
Filter = '/system.webServer/security/Access'
Name = 'sslFlags'
PSPath = 'MACHINE/WEBROOT/APPHOST'
Location = $SitePath
}
Get-WebConfigurationProperty @getWebConfigurationPropertySplat
View Set-WSUSContentDirAnonAuth.ps1
$Remediate = $false
Import-Module WebAdministration
$UseAppPoolIdentity = (Get-WebConfigurationProperty -Filter 'system.WebServer/security/authentication/AnonymousAuthentication' -Name username -Location 'WSUS Administration/Content') -eq ''
switch ($UseAppPoolIdentity) {
$true {
$true
}
$false {
switch ($Remediate) {
$true {
View Set-WSUSContentDir.ps1
$Remediate = $false
$PathShouldBeROOT = Get-ItemProperty -Path "registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Update Services\Server\Setup" -Name ContentDir | Select-Object -ExpandProperty ContentDir
$PathShouldBe = Join-Path -Path $PathShouldBeROOT -ChildPath 'WSUSContent'
[Void][Reflection.Assembly]::LoadWithPartialName("Microsoft.Web.Administration")
$serverManager = New-Object Microsoft.Web.Administration.ServerManager
$site = $serverManager.Sites | Where-Object { $_.Name -eq "WSUS Administration" }
$rootApp = $site.Applications | Where-Object { $_.Path -eq "/" }
$rootVdir = $rootApp.VirtualDirectories | Where-Object { $_.Path -eq "/Content" }
View Set-LEDBATWSUS.ps1
#region detection/remediation
#region define variables
$Remediate = $false
#endregion define variables
try {
$WSUS_Server = Get-WsusServer -ErrorAction Stop
switch ($WSUS_Server -is [Microsoft.UpdateServices.Internal.BaseApi.UpdateServer]) {
$true {
$WSUS_Port = $WSUS_Server | Select-Object -ExpandProperty PortNumber
View LEDBAT-Config.ps1
Set-NetTCPSetting -SettingName InternetCustom -CongestionProvider LEDBAT
New-NetTransportFilter -SettingName InternetCustom -LocalPortStart 8530 -LocalPortEnd 8530 -RemotePortStart 0 -RemotePortEnd 65535
View Get-HINV-Frequency-Filtered.sql
/*
This query will show you the count of records per Hardware Inventory class in your HinvChangeLog table for a period between
21 days ago, and 28 days ago
*/
SELECT map.DisplayName
, map.InvClassName AS 'Inventory View'
, COUNT(HINV.RecordID)
FROM HinvChangeLog hinv
LEFT JOIN v_GroupMap map ON map.GroupID = hinv.GroupKey
WHERE hinv.TimeKey > DATEADD(day, -28, GETDATE()) AND hinv.TimeKey < DATEADD(day, -21, GETDATE())
View Get-HINV-Frequency.sql
/*
This query will show you the count of records per Hardware Inventory class in your HinvChangeLog table.
This can help you identify a class that is create a lot of hardware inventory 'traffic' and potentially bloating
your database.
*/
SELECT map.DisplayName
, map.InvClassName AS 'Inventory View'
, COUNT(HINV.RecordID)
FROM HinvChangeLog hinv
LEFT JOIN v_GroupMap map ON map.GroupID = hinv.GroupKey
You can’t perform that action at this time.