Powershell Rest Demo

  • Posted on: 20 October 2014
  • By: Nate Jones

Have you ever wondered if the number of siblings that a person has makes them more or less likely to be president? This is a demo I wrote to show usage of REST APIs from Powershell. This example uses the Invoke-RestMethod in order to call the Freebase API. First we search for all US Presidents. Then we retrieve the list of their siblings. The script displays the number of siblings that each president had and then prints the average number of siblings over all of them.


Create A Random File Using Powershell

  • Posted on: 21 August 2014
  • By: Nate Jones

I recently needed to create a file for testing the upload capabilities on a website. The content of the file didn't matter, only the size. So I wrote this little powershell script to dump a random series of bytes to disk.

  1. #Create the array of the size you want
  2. $out = New-Object Byte[] 1024
  3. #Fill the array using a System.Random object
  4. (New-Object Random).NextBytes($out)
  5. #Write the array to a file with System.IO.File
  6. [IO.File]::WriteAllBytes('filename', $out)