I am trying to fix a script that automatically opens a page in edge and logs in. i can get it to open the page but the script errors out without entering the login info or directing to the desired final destination. the internal server page uses j_username and j_password to id the location where the credentials are entered. Im fairly new to coding and would like help to understand what im doing wrong and what i could be doing better.
Here is the code:
$ie = New-Object -ComObject 'msedge.Application'
$ie.Visible= $true # Make it visible
start microsoft-edge:http://internal URL to company
$usernmae="user"
$password="password"
While ($ie.Busy -eq $true) {Start-Sleep -Seconds 5;}
$usernamefield = $ie.document.getElementByID('j_username')
$usernamefield.value = $username
$passwordfield = $ie.document.getElementByID('j_password')
$passwordfield.value = $password
$Link = $ie.document.getElementByID('login-submit')
$Link.click()
{Start-Sleep -Seconds 10;}
start microsoft-edge:http://final destination internal URL to company
$ie.Quit()
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…