PowerShell Script Grab Random Pet Picture

Need to grab a random picture for validation inputs from the command line. This script will pull down a random pet picture (cat/dog)

$second = (Get-Date).Second
$url = ""
if (((($second /2) - [math]::Truncate($second / 2)) * 10) -eq 5) {
	$url = (Invoke-WebRequest "https://api.thecatapi.com/v1/images/search" | ConvertFrom-Json | Select-Object).url
}
else {
	$url = (Invoke-WebRequest "https://dog.ceo/api/breeds/image/random" | ConvertFrom-Json | Select-Object -Property message).message
}

$filename = $url.Substring($url.LastIndexOf("/") + 1)
$imagePath = "$env:temp\$filename"
Invoke-WebRequest $url -OutFile $imagePath
Invoke-Item $imagePath