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
2af3f34d58
commit
2a5f3754e7
1 changed files with 4 additions and 1 deletions
|
@ -25,7 +25,7 @@ $result = New-Object psobject @{
|
||||||
changed = $false
|
changed = $false
|
||||||
};
|
};
|
||||||
|
|
||||||
$win32_os = Get-WmiObject Win32_OperatingSystem
|
$win32_os = Get-CimInstance Win32_OperatingSystem
|
||||||
$osversion = [Environment]::OSVersion
|
$osversion = [Environment]::OSVersion
|
||||||
$memory = @()
|
$memory = @()
|
||||||
$memory += Get-WmiObject win32_Physicalmemory
|
$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_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 = @()
|
$ips = @()
|
||||||
Foreach ($ip in $netcfg.IPAddress) { If ($ip) { $ips += $ip } }
|
Foreach ($ip in $netcfg.IPAddress) { If ($ip) { $ips += $ip } }
|
||||||
Set-Attr $result.ansible_facts "ansible_ip_addresses" $ips
|
Set-Attr $result.ansible_facts "ansible_ip_addresses" $ips
|
||||||
|
|
Loading…
Reference in a new issue