ansible-collections / ansible.windows

Windows core collection for Ansible
https://galaxy.ansible.com/ansible/windows
GNU General Public License v3.0
254 stars 171 forks source link

Feature request: ansible_os_install_date fact #663

Closed Yannik closed 1 month ago

Yannik commented 1 month ago
SUMMARY

I would really appreciate having a ansible_os_install_date fact. Managing more than 200 win servers with ansible, things sometimes need to be rolled out to newer servers first, before applying these changes to the older ones.

The OS Install date can be determined with: Get-CimInstance Win32_OperatingSystem |Select-Object -ExpandProperty InstallDate

ISSUE TYPE
COMPONENT NAME

setup

jborean93 commented 1 month ago

Does this fact exist in another location like the registry. We are trying to avoid adding any extra calls to WMI/CIM because it slows the overall module down and non-admins cannot access this information.

It looks like it may be present on the InstallTime registry value

$osInfo = Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' -Name InstallTime
[DateTime]::FromFileTime($osInfo.InstallTime)

# Saturday, 15 June 2024 7:39:16 PM

Get-CimInstance Win32_OperatingSystem |Select-Object -ExpandProperty InstallDate

# Saturday, 15 June 2024 7:39:16 PM
Yannik commented 1 month ago

@jborean93 Using InstallTime registry value seems good to me.

Yannik commented 4 weeks ago

Thank you! :-)