Quantcast
Channel: /r/powershell – How to Code .NET
Viewing all articles
Browse latest Browse all 8793

Script works in POSH V4…not in V5

$
0
0

I upgraded to powershell v5 today, and this script stopped working. I verified it works on other machines with V4 installed:

$UserID = "user" $ie = New-Object -ComObject 'internetExplorer.Application' -ErrorAction stop $ie.Visible= $True # True = Visible, False = Invisible $ie.Navigate("website.com/gohere") Start-Sleep -Seconds 10 $UserIDField = $ie.Document.getElementByID("MainContent_InputBox") $UserIDField.value = $UserID $Link = $ie.Document.getElementByID("MainContent_QueryButton") $Link.click() Start-Sleep -Seconds 5 $Terminate = $ie.Document.getElementByID("MainContent_ResetPasswordButton") $Terminate.click() start-sleep -Seconds 2 #$Confirm = $ie.Document.getElementByID('MainContent_ConfirmButton') #$Confirm.click() Start-Sleep -seconds 10 $ie.Quit() 

I get an error:

You cannot call a method on a null-valued expression.At line:9 char:5 + $UserIDField = $ie.Document.getElementByID("MainContent_InputBox" ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull 

submitted by /u/MoneyMiddleton
[link] [comments]

The post Script works in POSH V4…not in V5 appeared first on How to Code .NET.


Viewing all articles
Browse latest Browse all 8793

Latest Images

Trending Articles



Latest Images