|
| 1 | +--- |
| 2 | +title: Remediate non-compliant Azure Automation State Configuration servers |
| 3 | +description: How to reapply configurations on demand to servers where the configuration state has drifted |
| 4 | +services: automation |
| 5 | +ms.service: automation |
| 6 | +ms.subservice: dsc |
| 7 | +author: mgreenegit |
| 8 | +ms.author: migreene |
| 9 | +ms.topic: conceptual |
| 10 | +ms.date: 07/17/2019 |
| 11 | +manager: nirb |
| 12 | +--- |
| 13 | +# Remediate non-compliant DSC servers |
| 14 | + |
| 15 | +When servers are registered with Azure Automation State Configuration, |
| 16 | +the 'Configuration Mode' is set to ApplyOnly, ApplyandMonitor, or ApplyAndAutoCorrect. |
| 17 | +If the mode isn't set to AutoCorrect, |
| 18 | +servers that drift from a compliant state for any reason |
| 19 | +will remain non-compliant until they're manually corrected. |
| 20 | + |
| 21 | +Azure compute offers a feature named Run Command |
| 22 | +that allows customers to run scripts inside virtual machines. |
| 23 | +This document provides example scripts for this feature |
| 24 | +when manually correcting configuration drift. |
| 25 | + |
| 26 | +## Correct drift of Windows virtual machines using PowerShell |
| 27 | + |
| 28 | +For step by step instructions using |
| 29 | +the Run Command feature on Windows virtual machines, see the documentation page |
| 30 | +[Run PowerShell scripts in your Windows VM with Run Command](/azure/virtual-machines/windows/run-command). |
| 31 | + |
| 32 | +To force an Azure Automation State Configuration node |
| 33 | +to download the latest configuration and apply it, |
| 34 | +use the `Update-DscConfiguration` cmdlet. |
| 35 | +For details, see the |
| 36 | +cmdlet documentation [Update-DscConfiguration](/powershell/module/psdesiredstateconfiguration/update-dscconfiguration). |
| 37 | + |
| 38 | +```powershell |
| 39 | +Update-DscConfiguration -Wait -Verbose |
| 40 | +``` |
| 41 | + |
| 42 | +## Correct drift of Linux virtual machines |
| 43 | + |
| 44 | +Similar functionality isn't currently available for Linux servers. |
| 45 | +The only option is to repeat the registration process. |
| 46 | +For Azure nodes, |
| 47 | +drift-correction can be done from the portal |
| 48 | +or using Az Automation cmdlets. |
| 49 | +Details about this process are documented in the page |
| 50 | +[Onboarding machines for management by Azure Automation State Configuration](/azure/automation/automation-dsc-onboarding#azure-portal). |
| 51 | +For hybrid nodes, |
| 52 | +drift-correction can be done using the included Python scripts. |
| 53 | +See the documentation in |
| 54 | +[PowerShell DSC for Linux repo](https://github.com/Microsoft/PowerShell-DSC-for-Linux#performing-dsc-operations-from-the-linux-computer). |
| 55 | + |
| 56 | +## Next steps |
| 57 | + |
| 58 | +- For PowerShell cmdlet reference, see [Azure Automation State Configuration cmdlets](/powershell/module/azurerm.automation/#automation) |
| 59 | +- To see an example of using Azure Automation State Configuration in a continuous deployment pipeline, see [Continuous Deployment Using Azure Automation State Configuration and Chocolatey](automation-dsc-cd-chocolatey.md) |
0 commit comments