I have a simple powershell script that opens a ur and logs whether it was successful:
$LogFile = ".\userLoad.log"
$Date = Get-Date
Try
{
$Request = [System.Net.WebRequest]::Create("http://dxscrumassist.zhi.com/maintenance/loadusers.aspx")
$Response = $Request.GetResponse()
$LogString = "$Date - User Load Success"
$Response.Close()
}
Catch
{
$LogString = "$Date - User Load Failure"
}
Add-content $LogFile -value $LogString
When I run the program from PowerShell ISE it works fine and logs as expected:
powershell.exe -executionpolicy bypass -file C:\AAA\loadUsers.ps1
When I run the exact same file from the Windows command line I am not getting a log file entry. What am I doing wrong?