https://docs.ansible.com/ansible/latest/user_guide/playbooks_conditionals.html
On Mon, 3 Feb 2020 at 13:45, Rahul Rawat <[email protected]> wrote: > > Hi, > > I have to convert PowerShell Script (using if else condition) into anisble > task. > How we can work with condition in ansible tasks. > > Here is my powershell script. > > $officeInstalled = Get-WmiObject win32_product | where { $_.Name > -like "Microsoft Office*" } | select Name,Version > > if ($officeInstalled -is [array]) > { > # > # Office > # > > $registryPath="HKLM:\SOFTWARE\Classes\Word.Application\CurVer" > $reg = Get-ItemProperty -Path $registrypath > $Office_version = $reg.'(default)' > $Office_version=$Office_version.substring($Office_version.length - 2, 2) > > # Remove Microsoft Office policies (if they exist) > $registryPath=$HKEY+"Software\Policies\Microsoft\Office" > Remove-RegistryKey $registryPath > > # > # Office 2016 > # > > IF ($Office_version -eq "16") { > Write-Host "Office 2016" > > # > # Common > # > > # Disable 'Welcome to your new Office' dialog > $registryPath=$HKEY+"Software\Microsoft\Office\16.0\FirstRun" > Update-Registry $registryPath "BootedRTM" "1" DWORD > } > > regards, > Rahul > > -- > You received this message because you are subscribed to the Google Groups > "Ansible Project" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/d8ff25b8-d251-4860-9662-8106ffc0d524%40googlegroups.com. -- Dick Visser Trust & Identity Service Operations Manager GÉANT -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAL8fbwNYikgpWkbEMDzattZnrZK%2BP7_Z1B%2BHkFwySphObNbkGQ%40mail.gmail.com.
