Created
March 17, 2017 02:09
-
-
Save ronanmccoy/241bce0a1443360d476bb5d17bcefa03 to your computer and use it in GitHub Desktop.
Powershell URL Request
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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