diff --git a/patch-dc-controllers.yaml b/patch-dc-controllers.yaml index 7438fc1..ed4102e 100644 --- a/patch-dc-controllers.yaml +++ b/patch-dc-controllers.yaml @@ -1,20 +1,19 @@ ---- -- name: Patch DCs via JEA +- name: Patch Domain Controllers via JEA hosts: domain_controllers gather_facts: no - tasks: - - name: List available updates - ansible.windows.win_powershell: - Get-WindowsUpdate -MicrosoftUpdate -AcceptAll -IgnoreReboot - register: available_updates - changed_when: false + - name: Get available updates + win_shell: | + Invoke-Command -ConfigurationName DCMaintenance -ScriptBlock { Get-WindowsUpdate } - name: Install updates - ansible.windows.win_powershell: - Install-WindowsUpdate -MicrosoftUpdate -AcceptAll -Verbose - register: install_result - - + win_shell: | + Invoke-Command -ConfigurationName DCMaintenance -ScriptBlock { Install-WindowsUpdate -AcceptAll -AutoReboot } + - name: Get update history + win_shell: | + Invoke-Command -ConfigurationName DCMaintenance -ScriptBlock { Get-WUHistory } + - name: Restart domain controller + win_shell: | + Invoke-Command -ConfigurationName DCMaintenance -ScriptBlock { Restart-Computer -Force }