mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
added windows facts ansible_lastboot, ansible_uptime_seconds
switched OS object to Get-CimInstance since we need a DateTime object for lastbootuptime
This commit is contained in:
parent
1102afed43
commit
51154a6991
1 changed files with 4 additions and 1 deletions
|
@ -25,7 +25,7 @@ $result = New-Object psobject @{
|
|||
changed = $false
|
||||
};
|
||||
|
||||
$win32_os = Get-WmiObject Win32_OperatingSystem
|
||||
$win32_os = Get-CimInstance Win32_OperatingSystem
|
||||
$osversion = [Environment]::OSVersion
|
||||
$memory = @()
|
||||
$memory += Get-WmiObject win32_Physicalmemory
|
||||
|
@ -66,6 +66,9 @@ Set-Attr $result.ansible_facts "ansible_distribution_version" $osversion.Version
|
|||
|
||||
Set-Attr $result.ansible_facts "ansible_totalmem" $capacity
|
||||
|
||||
Set-Attr $result.ansible_facts "ansible_lastboot" $win32_os.lastbootuptime.ToString("u")
|
||||
Set-Attr $result.ansible_facts "ansible_uptime_seconds" $([System.Convert]::ToInt64($(Get-Date).Subtract($win32_os.lastbootuptime).TotalSeconds))
|
||||
|
||||
$ips = @()
|
||||
Foreach ($ip in $netcfg.IPAddress) { If ($ip) { $ips += $ip } }
|
||||
Set-Attr $result.ansible_facts "ansible_ip_addresses" $ips
|
||||
|
|
Loading…
Reference in a new issue