I prefer using format strings over embedded expressions (i.e. $()
). I find it more readable. Also, PowerShell creates properties on a hashtable for each key, so instead of indexing (i.e. $_['url']
) you can $_.url
.
$results.notvalid |
ForEach-Object { 'Incorrect status code returned from {0}, code: {1}'
-f $_.url,$_.statuscode } |
Write-Warning