Skip to content

Instantly share code, notes, and snippets.

@techthoughts2
Last active January 14, 2019 23:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save techthoughts2/ba9c177405300cf6c344f42a53b6fa53 to your computer and use it in GitHub Desktop.
Save techthoughts2/ba9c177405300cf6c344f42a53b6fa53 to your computer and use it in GitHub Desktop.
################################################################################
# The "nice" way to reset the LCM...
if (-not(Test-Path -Path 'C:\Temp')) { $null = New-Item -Path 'C:\Temp' -ItemType 'Directory'}
[DscLocalConfigurationManager()]
Configuration ResetLCM {
Param (
[String[]]
$NodeName
)
Node $NodeName {
Settings
{
ActionAfterReboot = 'ContinueConfiguration'
AllowModuleOverwrite = $false
CertificateID = $null
ConfigurationDownloadManagers = @{}
ConfigurationID = $null
ConfigurationMode = 'ApplyAndMonitor'
ConfigurationModeFrequencyMins = 15
DebugMode = @('NONE')
MaximumDownloadSizeMB = 500
RebootNodeIfNeeded = $True
RefreshFrequencyMins = 30
RefreshMode = 'PUSH'
ReportManagers = @{}
ResourceModuleManagers = @{}
SignatureValidations = @{}
StatusRetentionTimeInDays = 10
}
}
}
$null = ResetLCM -NodeName 'localhost' -OutputPath 'C:\Temp\ResetLCM'
Set-DscLocalConfigurationManager -Path 'C:\Temp\ResetLCM' -ComputerName 'localhost'
Remove-DscConfigurationDocument -Stage Current, Pending, Previous -Verbose
################################################################################
# If you REALLY want to force kill the LCM, do this!
Remove-Item C:\windows\system32\Configuration\*.mof*
Get-Process wmi* | Where-Object {?_.modules.ModuleName -like "*DSC*"} | Stop-Process -force
Remove-DscConfigurationDocument -Stage Current, Pending, Previous -Verbose
################################################################################
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment