All,
I am trying to execute a powershell script in windows scheduler and getting the following error. “cannot call a method on a null-valued expression”. The script runs fine when I execute outside the scheduler. The script logs in to a web page with credentials and has to click on a navigation-tab to enter additional details. The script fails where it tries to “click” the navigation tab. I am using Powershell version 2.0 on windows 2008 R2 and the IE version is 11.0.9600.18524.
here is the html piece from the webpage
<ul>
<li>
<a href="#voice">My Voice</a> </li>
<li>
<a href="#Handling">Extension </a> </li>
Here is the code where it is failing in scheduler. (the code works well outside scheduler)
($IE.Document.getElementsByTagName(“a”) | where { $_.innerText -match “Extension” }).click()
I tried to search with href , but still it returns null value while executing through windows scheduler. But works well when executed outside scheduler.
($IE.Document.getElementsByTagName(“a”) | ?{$_.href -match “`#Handling”}
Any one has any suggestions to make it work in scheduler.
Thanks