AnsiblePilot — Master Ansible Automation
AnsiblePilot is the leading resource for learning Ansible automation, DevOps, and infrastructure as code. Browse over 1,100 tutorials covering Ansible modules, playbooks, roles, collections, and real-world examples. Whether you are a beginner or an experienced engineer, our step-by-step guides help you automate Linux, Windows, cloud, containers, and network infrastructure.
Popular Topics
About Luca Berton
Luca Berton is an Ansible automation expert, author of "Ansible for VMware by Examples" and "Ansible for Kubernetes by Example" published by Apress, and creator of the Ansible Pilot YouTube channel. He shares practical automation knowledge through tutorials, books, and video courses to help IT professionals and DevOps engineers master infrastructure automation.
Check .NET Framework Version on Windows with Ansible — Video Tutorial
Learn how to check the .NET Framework version on Windows systems with Ansible using the win_reg_stat module. Includes a practical Playbook example and execution results.
What You'll Learn
- How to Check the .NET Framework version on Windows-like systems with Ansible?
- Ansible read Windows Registry
- Parameters & Return Values
- Parameters
- Main Return Values
- Links
- code
- execution
- idempotency
- manual check
Full Tutorial Content
How to Check the .NET Framework version on Windows-like systems with Ansible?
The principle is to read the right Windows Registry key, store in a variable, and display it on the screen.
I'm going to show you a live Playbook and some simple Ansible code.
I'm Luca Berton and welcome to today's episode of Ansible Pilot
Ansible read Windows Registry
- `ansible.windows.win_reg_stat`
- Get information about Windows registry keys
Today we're talking about the Ansible module `win_reg_stat`.
The full name is `ansible.windows.win_reg_stat`, which means that is part of the collection of modules specialized to interact with Windows target host.
It's a module pretty stable and out for years.
It works in Windows and Windows Server operating systems.
It gets information about Windows registry keys.
Parameters & Return Values
Parameters
- path string - The full registry key path including the hive to search for
- name string - key path including the hive to search for
Main Return Values
- exists, value, raw_value, type, sub_keys
The only mandatory parameter is "path" which is the full registry key path including the hive to search for.
You probably would like to specify also the "name" of the key path including the hive to search for.
The module returns multiple properties.
The most useful are "exists" if the key/property exist in the registry,
The value of the key is accessible via the "value" and "raw_value" attributes.
Other useful attributes are "type" for the property type and "sub_key" for a list of all the subkeys of the key specified.
Links
- [ansible.windows.win_reg_stat](https://docs.ansible.com/ansible/latest/collections/ansible/windows/win_reg_stat_module.html)
- [How to: Determine which .NET Framework versions are installed](https://learn.microsoft.com/en-us/dotnet/framework/migration-guide/how-to-determine-which-versions-are-installed)
## Playbook
How to check the .NET Framework version on Windows-like systems accessing the Windows Registry with Ansible Playbook.
Specifically, the Windows Registry key is "Version" located in `HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full`.
code
```yaml
---
- name: win_reg_stat module Playbook
hosts: all
tasks:
- name: check .NET version
ansible.windows.win_reg_stat:
path: 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full'
name: "Version"
register: reg_val
- name: print .NET version
ansible.builtin.debug:
msg: "{{ reg_val }}"
```
execution
```bash
ansible-pilot $ ansible-playbook -i virtualmachines/win/inventory windows/printdotnet.yml
PLAY [win_reg_stat module Playbook] *************************************************************
TASK [Gathering Facts] **********************************************************************
ok: [WindowsServer]
TASK [check .NET version] *******************************************************************
ok: [WindowsServer]
TASK [print .NET version] *******************************
About This Tutorial
- Author: Luca Berton
- Difficulty: Beginner
- Read time: 3 min
- Category: installation
Read the full written article: Check .NET Framework Version on Windows with Ansible
Related Video Tutorials
- Add Windows Registry on Windows-like systems - Ansible module win_regedit — Learn how to use Ansible win_regedit module to add, change, or remove Windows registry key-values efficiently and accurately with simple Ansible code examples.
- Ansible win_regedit: Manage Windows Registry Keys & Values (Examples) — How to manage Windows Registry with Ansible win_regedit module. Create, modify, and remove registry keys and values with practical automation examples.
- Ansible win_file Module: Create Directory on Windows Hosts (Guide) — How to create directories on Windows with Ansible win_file module (ansible.windows.win_file). Set paths, manage folders, handle permissions. Practical YAML playbook examples for Windows automation.
- Ansible win_file Module: Create & Manage Files on Windows (Guide) — How to create and manage files on Windows with Ansible win_file module (ansible.windows.win_file). Create files, directories, symlinks on Windows. Practical YAML playbook examples.
- Ansible Windows Update: Rolling Updates with win_updates Module (Guide) — How to manage Windows Updates with Ansible win_updates module. Rolling updates, selective patching, reboot handling, and WSUS integration with playbook examples.
- Ansible synchronize Module: Rsync Files & Directories Between Hosts — Discover how to use Ansible synchronize module for efficient file backups with rsync. Learn practical steps and see real-world examples for Linux systems.