# 2.1
New-Object -TypeName psobject -Property @{ 
    Name       = 'Nicolas BAUDIN' 
    Email      = 'nicolas.baudin@frpsug.com' 
    Age        = 25 
    PostalCode = 44000 
} 

$Hash = [ordered]@{ 
    Name       = 'Nicolas BAUDIN' 
    Email      = 'nicolas.baudin@frpsug.com' 
    Age        = 25 
    PostalCode = 44000 
} 
New-Object -TypeName psobject -Property $Hash 

[PSCustomObject]@{ 
    Name       = 'Nicolas BAUDIN' 
    Email      = 'nicolas.baudin@frpsug.com' 
    Age        = 25 
    PostalCode = 44000 
}

# 2.2
$Computer1 = [PSCustomObject]@{ 
    ComputerName = 'PC01-IT' 
    SerialNumber = 'SN00001' 
    IP           = '192.168.0.10' 
}
Add-Member -InputObject $Computer1 -TypeName MyComputer `
    -NotePropertyMembers @{Commissioning = [datetime]'01/16/2015' }


$GetComputerAge = { 
    [int]((New-TimeSpan -End (Get-Date) `
                -Start ($this.Commissioning)).totaldays / 365) 
} 

Add-Member -InputObject $Computer1 -Name GetComputerAge `
    -MemberType ScriptMethod -Value $GetComputerAge 
    
$Computer1.GetComputerAge() 


## 2.3
$Computer1 = [PSCustomObject]@{ 
    ComputerName = 'PC01-IT' 
    SerialNumber = 'SN00001' 
    IP           = '192.168.0.10' 
} 
$Computer2 = [PSCustomObject]@{ 
    ComputerName = 'PC02-IT' 
    SerialNumber = 'SN00002' 
    IP           = '192.168.0.11' 
} 
$Computer3 = [PSCustomObject]@{ 
    ComputerName = 'PC03-IT' 
    SerialNumber = 'SN00003' 
    IP           = '192.168.0.12' 
}

$AllComputer = @($Computer1, $Computer2, $Computeur3) 
$AllComputer

$AllComputer = @() 
$AllComputer += $Computer1 
$AllComputer += $Computer2 
$AllComputer += $Computer3 
$AllComputer


Foreach ($Computer in $AllComputer) { 
    $Ping = Test-Connection $Computer.IP -Count 1 -Quiet 
    Write-Out "Test de ping sur $($Computer.ComputerName) : $Ping" 
}

# 2.4
$Obj = Get-WmiObject Win32_DiskDrive | 
    Select-Object Model, Status, InterfaceType, 
    @{Name = 'NbPartitions'; Expression = { $_.Partitions } }, 
    @{n = 'SizeGB'; e = { "{0:N2}" -f $($_.Size / 1GB) } } 
