Random Password Generator in PowerShell

Here is a quick and dirty PowerShell script that you can use to generate pseudo-random passwords using dictionary words, numbers and special characters.

This kind of script is good for environments such as schools and universities where mass-enrolment is quite common before the start of the academic year.

You can incorporate the function in your own script or come up with something new.

Credit goes to setgetgo.com for making the random word generator API available for public use.

The code is available on my GitHub page and is a good place to check for the latest iteration of code as well as some examples. Below is the code as of 14/06/2016

<#
	.SYNOPSIS
		Generate a random password
	
	.DESCRIPTION
		Uses the setgetgo.com random word API to generate random words. A random number and special character is then appended
	
	.PARAMETER numberOfPasswords
		Number of passwords to generate. Default is 1.
	
	.PARAMETER wordLength
		Word length. Default is 8.
	
	.PARAMETER allowedSpecialCharacters
		Special characters that are allowed to be appended to the password. Default is ! * and ?
		If defining your own, use the format:
		Generate-Password -allowedSpecialCharacters "!","?",",","/"
	
	.PARAMETER maximumNumber
		Default number to append to word will be between 0 and 999.
	
	.EXAMPLE
		PS C:\> Generate-Password
		This will generate a random 8 character word, append a number between 0 and 999 and finally append a special character.
	
	.NOTES
		Additional information about the function.
#>
function Generate-Password
{
	[CmdletBinding()]
	[OutputType([string])]
	param
	(
		[Parameter(Mandatory = $false)]
		[int]$numberOfPasswords = 1,
		[Parameter(Mandatory = $false)]
		[int]$wordLength = 8,
		[Parameter(Mandatory = $false)]
		$allowedSpecialCharacters = @('!', '*', '?'),
		[Parameter(Mandatory = $false)]
		[int]$maximumNumber = 999
	)
	
	for ($i = 1; $i -le $numberOfPasswords; $i++)
	{
		$randomWord = Invoke-WebRequest -URI http://randomword.setgetgo.com/get.php?len=$wordLength
		$randomNumber = Get-Random -Maximum $maximumNumber
		$randomSpecialCharacter = $allowedSpecialCharacters | Get-Random
		Write-Output "$($randomWord.content)$randomNumber$randomSpecialCharacter"
	}
}

Office 365 Quarantine Tool

If you find yourself using the Office 365 (Exchange Online) e-mail quarantine often then you probably know how frustrating and slow it can be to quickly find and release quarantined items. Often times you’ll find yourself waiting for a few minutes only to realise it’s not doing anything. Then you have to refresh the page and re-enter your search criteria. The fact you can’t even wildcard searches is also unforgivable (it’s 2016 Microsoft, why can we not wildcard search the subject and sender fields?!)

This annoyance coupled with my eagerness to play with PowerShell led me to develop a quick and dirty quarantine tool or viewer if you like. The tool is quite basic but it will let you do the following:

  • Wildcard search the subject and sender fields
  • Configure the number of results to return
  • Release a message based on message ID

2016-06-07 20_17_07-Office 365 Quarantine Tool v012016-06-07 20_19_19-Office 365 Quarantine Tool v01
If you want to have a play with the tool, it’s on my GitHub along with the source code if you feel like suggesting some improvements.

Setting up a RTSP Relay with Live555 Proxy

In this brief how-to, I will show you how you can set up a RTSP relay/proxy server using the Live555 Proxy.

Essentially what the Live555 proxy server allows you to do is to connect to a backend video feed and relay it to your RTSP clients via unicast. The number of clients you can relay to depends on the hardware of your proxy server as well as the network. Bandwidth usage can easily be calculated by multiplying the backend feed in KB/s by the number of clients connected to your relay server.

Continue reading Setting up a RTSP Relay with Live555 Proxy

WordPress 4.4.1 Redirect Loop

You notice you receive one of the following errors whilst trying to browse to the home page of one of your WordPress sites after updating to 4.4.1:

ERR_TOO_MANY_REDIRECTS
This webpage has a redirect loop
This page isn't redirecting properly

I saw this on one of the WordPress sites I manage for a local takeaway. The problem occurred after the update to 4.4.1 and had me stumped.

All other pages would load but not the static homepage. Changing the permalink structure to plain (post-id) fixed the problem but changing it back to postname made the problem reappear.

Interestingly, if I browsed http://homepage/index.php or http://homepage// (yes, a double slash) the home page would load up just fine. Weird. I’m sure a .htaccess rule would fix this but I didn’t delve in to this.

The solution?

Simple. Check your WordPress address and Site Address in Settings –> General.

Ensure they’re both lower cased and not mixed. Don’t ask me why or how this works because I have no idea.