Powershell Scripting Games - Day 2
Here is my solution for Day 2 - Beginner
All the information is retrieved from WMI
#First we get the info from WMI
$computer = "Localhost"
$mycomp = Get-WmiObject Win32_Processor -ComputerName $computer
# We Output our Info
Write-Host -ForegroundColor Green "Strength Evaluation for" $computer
Write-Host -ForegroundColor Yellow "Speed:" $mycomp.MaxClockSpeed"Mhz"
Write-Host -ForegroundColor Yellow "L2 Cache Size:" $mycomp.L2CacheSize
#We will check if the data is null or not
if ($mycomp.L2CacheSpeed -eq $null) {
$L2CacheSpeed = "Data is not Available"
Write-Host -ForegroundColor Red "L2 Cache Speed:" $L2CacheSpeed
}
else {
$L2CacheSpeed = $mycomp.L2CacheSpeed
Write-Host -ForegroundColor Yellow "L2 Cache Speed:" $L2CacheSpeed
}
Write-Host -ForegroundColor Yellow "L3 Cache Size:" $mycomp.L3CacheSize
#We will check if the data is null or not
if ($mycomp.L3CacheSpeed -eq $null) {
$L3CacheSpeed = "Data is not Available"
Write-Host -ForegroundColor Red "L3 Cache Speed:" $L3CacheSpeed
}
else {
$L3CacheSpeed = $mycomp.L3CacheSpeed
Write-Host -ForegroundColor Yellow "L3 Cache Speed:" $L3CacheSpeed
}
Write-Host -ForegroundColor Magenta "Strength ..."
Write-Host -ForegroundColor Magenta "Number of Cores:" $mycomp.NumberOfCores
Write-Host -ForegroundColor Magenta "Number of Logical Cores:" `
$mycomp.NumberOfLogicalProcessors
Write-Host -ForegroundColor Magenta "Processor Name:" $mycomp.Name
Write-Host -ForegroundColor Cyan "Agility ..."
Write-Host -ForegroundColor Cyan "Adress Width:" $mycomp.AddressWidth