Skip to content

Instantly share code, notes, and snippets.

@ronanmccoy
Created March 17, 2017 02:09
Show Gist options
  • Save ronanmccoy/241bce0a1443360d476bb5d17bcefa03 to your computer and use it in GitHub Desktop.
Save ronanmccoy/241bce0a1443360d476bb5d17bcefa03 to your computer and use it in GitHub Desktop.
Powershell URL Request
$url = "http://www.google.com"
$log_file = "C:\MyScriptLogs\pwscript.logs"
$date = get-date -UFormat "%d/%m/%Y %R"
"$date [INFO] Execution of $url" >> $log_file
$other_file = "C:\MyScriptLogs\response.log"
$request = [System.Net.WebRequest]::Create($url)
$response = $request.GetResponse()
$response >> $other_file
$response.Close()
#
# To set up as a scheduled task, see https://community.spiceworks.com/how_to/17736-run-powershell-scripts-from-task-scheduler
#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment