Computer info template/example (quick and dirty)

A quick and dirty script to get computer info

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#WMI

$cred = get-credential

$computers = "test-www11", "test-www12"

$data = foreach ($computer in $computers) {
Get-WmiObject win32_operatingsystem -Credential $cred -ComputerName $computer |
Select-Object @{n="Name";e={$_.pscomputername}},
@{n="OS";e={$_.caption}},
@{n="Installed";e={$_.converttodatetime($_.installdate)}},
@{n="Uptime";e={(get-date) - $_.converttodatetime($_.Lastbootuptime)}},
OSarchitecture,
@{n="PS Version";e={(Invoke-Command -ComputerName $computer -credential $cred {$PSVersionTable.PSVersion.ToString()})}}

}

$data | Format-Table

#CIM

$computers = Invoke-Command -ComputerName mon-dc11 -Credential $cred {(Get-ADComputer -filter 'name -like "MON-*"' | where enabled -eq $true).name}

New-CimSession -ComputerName $computers -Credential $cred
$CS = Get-CimSession

$data = foreach ($computer in $computers) {
Get-CimInstance win32_operatingsystem -CimSession $cs|
Select-Object @{n="Name";e={$_.pscomputername}},
@{n="OS";e={$_.caption}},
@{n="Installed";e={$_.installdate}},
@{n="Uptime";e={(get-date)-$_.Lastbootuptime}},
OSarchitecture,
@{n="PS Version";e={(Invoke-Command -ComputerName $computer -credential $cred {$PSVersionTable.PSVersion.ToString()})}}

}

$data | Format-Table