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.
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.
- #Create the array of the size you want
- $out = New-Object Byte 1024
- #Fill the array using a System.Random object
- (New-Object Random).NextBytes($out)
- #Write the array to a file with System.IO.File
- [IO.File]::WriteAllBytes('filename', $out)