views:

51

answers:

0

Hello,

some problem with a PowerShell script.

I want to use the script to download a newspaper everday day using the Windows XP task manager.

I scipt the code in PowerShell ISE and it works fine. But when i try to run the code in a normal powershell instance i get following exception caused by this piece of code

$ie2.Document.getElementsByTagName("frame") | 
foreach {
    if($_.name -eq  "content") {

        # Next line causes exception**
        $_.contentWindow.Document.getElementsByTagName("frame") |
        foreach {
            if($_.name -eq "cn") {

Exception

+ $_.contentWindow.Document.getElementsByTagName <<<< ("frame") |
    + CategoryInfo          : InvalidOperation: (getElementsByTagName:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

Get-Host

Name             : ConsoleHost
Version          : 2.0
InstanceId       : ec6539ba-7a3a-429b-aec9-69861d4712bf
UI               : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture   : de-DE
CurrentUICulture : de-DE
PrivateData      : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
IsRunspacePushed : False
Runspace         : System.Management.Automation.Runspaces.LocalRunspace

Thanks for help.

related questions