- name: Stop IIS
ansible.windows.win_service:
name: W3SVC
state: stopped
and
ansible.windows.win_powershell
$service = "W3SVC"
Stop-Service $service
Start-Sleep -Seconds 20
do {
$running = Get-Service $service
Start-Sleep -Seconds 5
}
while($running.Status -ne "Stopped")