Powershell : This operation returned because the timeout period expiredAt -


i trying run xtestplan_1.ps1 enable_local.ps1.

while enable_local.ps1 on local machine, xtestplan_1.ps1 on network drive. have shortcut xtestplan_1.ps1 on local machine.

here enable_local.ps1:

$item = "d:\temp\xtestplan_1.lnk" writeinlogfile "$item" try {     & "$item" } catch {     writeinlogfile $error } 

while running code, sometimes, error:

program "xtestplan_1.lnk" failed run: operation returned because timeout period expired @ d:\temp\enable_local.ps1.

this script works expected, not work. xtestplan_1.ps1 exist on network drive.

trying execute shortcut isn't way run script.

a better call script directly:

$item = "\\server\share\xtestplan_1.ps1" writeinlogfile "$item" try {     & $item } catch {     writeinlogfile $error } 

if must use shortcut reason, can target path shortcut , call script itself.

$item = "d:\temp\xtestplan_1.lnk"  $shellobj = new-object -com wscript.shell $targetpath = $shellobj.createshortcut($item).targetpath  writeinlogfile "$targetpath" try {     & $targetpath } catch {     writeinlogfile $error } 

Comments