#get number of cores $cpu = Get-WmiObject win32_processor | Select-Object Numberoflogicalprocessors $cores = [convert]::ToInt32($cpu.Numberoflogicalprocessors, 10) #define functions function get-prime($i){ for ($a=3; $a -lt $i; $a++){ if ($i % $a -eq 0){ return "no" } else{} } } #create a task for each core foreach ($core in 1..$cores){ start-job -ScriptBlock { for ($i=1000000; $i -le 10000000; $i++){ $prime = get-prime($i) if ($prime -ne "no"){ write-output "$i" } else {} } } } Wait-job * clear Receive-Job * remove-job
Kategorie: Meta
I’m so meta even this acronym.
Snoverisms: POSH – Like programming with hand grenades Sticker
I stumbled upon a post in /r/powershell which linked to this site: http://snoverisms.com/
I liked the first quote so much that I made a sticker with a Silhouette printer!
Here’s the PNG (In Silhouette you have to insert PNG’s and later convert them to svg like files … whatever):
Automatic Proxy Authentification from $Profile
Works if you’re behind an AD. Put this in your $Profile:
function auth-proxy{ netsh winhttp import proxy source=ie $webClient = new-object System.Net.WebClient $webClient.Proxy.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials } auth-proxy{}
MOTD for Powershell (Using the fortune-mod (linux) Package files)
I downloaded and altered the fortune-mod fortune files so that there’s one fortune per line. This can be downloaded here:
http://pastebin.com/TnxeyWJm
Next step is to add the following thing to your $Profile
function get-motd{ $fortunes = get-content \path\to\fortunes.txt get-random -InputObject $fortunes } ....... clear-host get-motd{}
It’s virtually important that you run the function after the clear-host. Otherwise the quote will not appear / will be erradicated before it even had time to present itself to you)