-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy path24_2.ps1
More file actions
22 lines (21 loc) · 889 Bytes
/
24_2.ps1
File metadata and controls
22 lines (21 loc) · 889 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
function Get-DiskInfo {
foreach ($domain in (Get-ADForest).domains) {
$hosts = Get-ADDomainController -filter * -server $domain |
Sort-Object -Prop hostname
ForEach ($h in $hosts) {
$cs = Get-CimInstance -ClassName Win32_ComputerSystem -ComputerName $h
$props = @{'ComputerName' = $h
'DomainController' = $h
'Manufacturer' = $cs.manufacturer
'Model' = $cs.model
'TotalPhysicalMemory(GB)'=$cs.totalphysicalmemory / 1GB
}
$obj = New-Object -Type PSObject -Prop $props #A
$obj.psobject.typenames.insert(0,'Toolmaking.DiskInfo') #B
Write-Output $obj
} #foreach $h
} #foreach $domain
} #function
Export-ModuleMember -function Get-DiskInfo
#A Saves the object to a variable
#B Inserts a new type name