Use Powershell to max out CPU usage

Posted: April 19, 2012 in Scripts, VMware

Every now and then, you have cause to want to max a machine or bunch of machines CPU. For example, to test out DRS in a VM farm. Here’s a simple Powershell code block to get the job done.

# Adjust the first for loop to reflect the number of available cores in the machine or twice as many if you want to be sure
ForEach ($Number in 1..4){

start-job -ScriptBlock{
$result = 1; foreach ($number in 1..2147483647) {$result = $result * $number}
}

}

Wait-Job *
Clear
Receive-Job *
Remove-job *

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s