Link to home
Start Free TrialLog in
Avatar of Mdamon808
Mdamon808Flag for United States of America

asked on

Powershell command works but script fails

I have a .ps1 file that I generated to add a registry key to extend the timeout length for Internet Explorer.

The command line work when run in PS, but when I convert it to a script it fails with the following error;

"New-ItemProperty : The property already exists.
At C:\Users\Dmaranya\IE_Timeout_Adjust.ps1:3 char:1
+ New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet ...
    + CategoryInfo          : ResourceExists: (HKEY_LOCAL_MACH...ternet Settings:String) [New-ItemProperty], IOExcepti
   on
    + FullyQualifiedErrorId : System.IO.IOException,Microsoft.PowerShell.Commands.NewItemPropertyCommand

Anyone know why the command line works but the script doesn't?
Avatar of Hankinater
Hankinater
Flag of United States of America image

Avatar of footech
Does the property already exist?  Are you using the -force parameter?

Care to share the script?
Avatar of Mdamon808

ASKER

Oops, it appears that I neglected to upload the file with my question. My bad, here it is.
IE-Timeout-Adjust.txt
ASKER CERTIFIED SOLUTION
Avatar of Raheman M. Abdul
Raheman M. Abdul
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yup that's done it. Thanks a bunch. As a side note why did I have to add the | out-null part of the line?
Out-Null means discard the output
-Force should have worked in your case.