powershell - Adding new item into XML output file -


i combined external ip address current hardware information output file.

pc info

#lists computer information $cpu = get-wmiobject -class win32_processor  $mb = get-wmiobject -class win32_baseboard $bios = get-wmiobject -class win32_bios -computername . #$user = get-wmiobject -class win32_computersystem $last = get-wmiobject -class win32_networkloginprofile |         {($_.numberoflogons -gt 0) -and ($_.numberoflogons -lt 65535)} |         select-object name,@{label='lastlogon';expression={$_.converttodatetime($_.lastlogon)}},numberoflogons  $props = @{                 "name"              = $cpu.name     "description"       = $cpu.description     "mb manufacturer"   = $mb.manufacturer     "mb product"        = $mb.product     "bios verison"      = $bios.smbiosbiosversion     "bios manufacturer" = $bios.manufacturer     "bios serial"       = $bios.serialnumber     "~last logon"       = $last } new-object psobject -property $props |  out-file c:\windows\script\ps_output3.xml 

external ip address

$wc=new-object net.webclient; $wc.downloadstring("http://checkip.dyndns.com") -replace "[^\d\.]" 

update 1 last question: how organize list?

something might help:

#lists computer information $cpu = get-wmiobject -class win32_processor  $mb = get-wmiobject -class win32_baseboard $bios = get-wmiobject -class win32_bios -computername . #$user = get-wmiobject -class win32_computersystem $dydns = invoke-webrequest http://checkip.dyndns.com/ -disablekeepalive $dyreg = $dydns.rawcontent -match '\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b' $last = get-wmiobject -class win32_networkloginprofile | {($_.numberoflogons -gt 0) -and ($_.numberoflogons -lt 65535)} | select-object  name,@{label='lastlogon';expression={$_.converttodatetime($_.lastlogon)}},numberoflogons $props = @{         "name"                    = $cpu.name     "description"             = $cpu.description     "mb manufacturer"       = $mb.manufacturer     "mb product"            = $mb.product     "bios verison"          = $bios.smbiosbiosversion     "bios manufacturer"     = $bios.manufacturer     "bios serial"           = $bios.serialnumber     "~last logon"            = $last     "dns"                 = $matches[0]      } new-object psobject -property $props |  out-file c:\test.csv 

Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

Kivy: Swiping (Carousel & ScreenManager) -