Check a list of urls in PowerShell to see what are valid

Recently, one of my colleagues was asked to check what of our products had images on our website and didn’t.

Being a typical developer, I didn’t like the idea of someone wasting energy on monotonous tasks like that when a machine could do it so much more accurately.

The outline of the code I used was:

$urls = @("","","http://this.doesnt.exist")

foreach($url in $urls)
$HTTP_Request = [System.Net.WebRequest]::Create($url)

 $HTTP_Response = $HTTP_Request.GetResponse()
 $HTTP_Status = [int]$HTTP_Response.StatusCode
catch [System.Net.WebException]
 Write-Host "$url is invalid."


The output for the above is: http://this.doesnt.exist is invalid.

This was a great start.
To complete this for the task at hand, I enhanced the code to populate the variable $urls with a list of all our products attached to the base image path.
This reduced the amount of time from hours to minutes to find all the missing images.

Easily see all members of an Active Directory Group

Recently I had an issue with SQL Server permissions and someone not being able to log into one of our development machines.

I knew that the instance had read access for everyone in a specific Active Directory Group. After trying to log in as the user and seeing the issue, I decided I better check if she was added to the group or not.

First thing I did was crack open the ever handy AD Explorer and found that searching for the group, (which took a long time in our environment) did not show me who was members.

I then remembered that there was a command line way to check the users.
So I clicked, Start, Run, typed in cmd.exe and in the command prompt  typed:
NET GROUP “group name here” /DOMAIN
net group
The output will show you the group name, the comment about the group and the members of it.