PowerShell S2E7 (CPU Stress)

Published: 20 August 2020
on channel: Mr Automation
953
8

*How to stress the CPU 100% with powershell
*stress your CPU with powershell
*max CPU load with powershell
*read-host
*write-warning
*start-job
*write-output
*foreach()

In this video I demonstrate how you can stress your CPU to the max with powershell. :-)


Code :

[cmdletbinding()]
param(
[parameter(mandatory=$true)][int]$NumHyperCores
)

Write-Output "============= CPU Stress Test Started: $(get-date) ============="
Write-Warning "This script will potentially max your CPU utilization!"
$Prompt = Read-Host "Are you sure you want to proceed? (Y/N)"

if ($Prompt -eq 'Y') {
Write-Warning "To cancel execution of all jobs, close the PowerShell Host Window."
Write-Output "Hyper Core Count: $NumHyperCores"
Measure-Command {
foreach ($loopnumber in 1..$NumHyperCores){
Start-Job -ScriptBlock{
$result = 1
foreach ($number in 1..214748369){
$result = $result * $number
}
}
}

Wait-Job *
Clear-Host
Receive-Job *
Remove-Job *
}
}
else{
Write-Output "Cancelled!"
}


Watch video PowerShell S2E7 (CPU Stress) online, duration hours minute second in high quality that is uploaded to the channel Mr Automation 20 August 2020. Share the link to the video on social media so that your subscribers and friends will also watch this video. This video clip has been viewed 953 times and liked it 8 visitors.