- 1 year ago
How to find 'product_id' for the 'win_package' Ansible module?
To find the product_id
for the win_package
Ansible module, you can follow these steps:
Identify the desired software package for which you want to find the
product_id
. Ensure that you have access to the installer or the installed software.Open a Command Prompt or PowerShell window on the Windows machine where the software is installed or where you have the installer available.
Run the following command to list all the installed software along with their
product_id
:shellwmic product get name,identifyingnumber
This command uses the
wmic
command-line tool to query the Windows Management Instrumentation (WMI) and retrieve the list of installed software packages along with theiridentifyingnumber
, which corresponds to theproduct_id
.Note: Depending on the system and user privileges, you may need administrative rights to run the
wmic
command.Look for the software package you're interested in and note down its
identifyingnumber
, which is theproduct_id
you need for thewin_package
Ansible module.For example, the output might look like:
cssIdentifyingNumber Name
{ABCD-1234-EFGH-5678} Software Package A
{WXYZ-9876-QWER-5432} Software Package B
In this case, if you're interested in "Software Package A," the corresponding
product_id
would be{ABCD-1234-EFGH-5678}
.
Once you have the product_id
for the software package, you can use it in the win_package
Ansible module by specifying the product_id
parameter. For example:
yaml- name: Install Software Package A
win_package:
product_id: "{ABCD-1234-EFGH-5678}"
state: present
Replace {ABCD-1234-EFGH-5678}
with the actual product_id
you obtained from the wmic
command output.
By following these steps, you can find the product_id
for the desired software package on a Windows machine and use it with the win_package
Ansible module for software installation or management.