Elizabeth,
I have a PowerShell script you can use:
#csv path; input must be in this schema: ID,URL,NOTES - format your input this way, or adjust script
$path = "C:\Users\YOU\Desktop\YOUR_CSV.csv" #in csv (you create)
$outPath = "C:\Users\YOU\Desktop\YOUR_OUT_CSV.csv" #out csv (don't create this... let script create for you)
$csv = Import-Csv -path $path
$OutArray = @()
function processURL($inURL){
# Create request
$HTTP_Request = [System.Net.WebRequest]::Create($inURL)
# Get response
$HTTP_Response = $HTTP_Request.GetResponse()
# Get response integer code
$HTTP_Status = [int]$HTTP_Response.StatusCode
If ($HTTP_Status -eq 200) {
$ret_val = "OK!"
}
Else {
$ret_val = "CHECK ME!"
}
# Clean-up and return
$HTTP_Response.Close()
return $ret_val
}
function request($ID, $URL, $NOTES){
$localResponse = processURL $URL
export $ID $URL $NOTES $localResponse
}
function export($eID, $eURL, $eNotes, $eResponse){
$myobj = "" | Select "ID","URL","NOTES", "RESPONSE"
$myobj.ID = $eID
$myobj.URL = $eURL
$myobj.NOTES = $NOTES
$myobj.RESPONSE = $eResponse
$OutArray += $myobj
$myobj = $null
#PS4 version:
$OutArray | export-csv $outPath -Append
#PS2 version:
#$OutArray | ConvertTo-Csv -NoTypeInformation | select -Skip 1 | Out-File -Append $outPath
}
foreach($line in $csv)
{
$properties = $line | Get-Member -MemberType Properties
for($i=0; $i -lt $properties.Count;$i++)
{
$column = $properties[$i]
$columnvalue = $line | Select -ExpandProperty $column.Name
switch ($column.Name)
{
"ID" {$ID = $columnvalue}
"URL" {$URL = $columnvalue}
"NOTES" {$NOTES = $columnvalue}
}
}
if (-Not [string]::IsNullOrEmpty($ID) -and -Not [string]::IsNullOrEmpty($URL)) { request $ID $URL $NOTES }
}
So, in my test, I used a csv like this:
ID,URL,NOTES
1,http://www.google.com, this is google
2,http://www.esri.com, this is esri
3,http://www.microsoft.com, this is microsoft
...and I got an output like this:
#TYPE Selected.System.String
"ID","URL","NOTES","RESPONSE"
"1","http://www.google.com","this is google","OK!"
"2","http://www.esri.com","this is esri","OK!"
"3","http://www.microsoft.com","this is microsoft","OK!"