for loop and start-job from cmd.exe
hello,
i have simple script developed debug purposes:
$serverlist = @( "sca-c1cor01", "scb-c1cor01" ) ($i=0; $i -lt $serverlist.length; $i++) { start-job -scriptblock {$x=0} }
i have saved script off file called test.ps1. when run ./test.ps1 within interactive powershell runs fine. i trying to call script dos window, sql server agent command job, or start->run line. here syntax using:
cmd.exe /c powershell -nologo -noninteractive "c:\scripts\powershell\test.ps1"
when run way (from dos window), diaglog box pops says:
powershell has stopped working problem caused program stop working correctly. windows close program , notify if solution available.
i close , open eventvwr.msc. 2 pieces of info. 1 application , services log (windows powershell):
engine state changed available stopped.
details:
newenginestate=stopped
previousenginestate=available
sequencenumber=10
hostname=consolehost
hostversion=2.0
hostid=1cb1812d-7fb8-460a-a2ad-cae0d31d1a4a
engineversion=2.0
runspaceid=39f941a4-6d6f-495d-acd8-c89dbd70aa8b
pipelineid=
commandname=
commandtype=
scriptname=
commandpath=
and 1 windows log (application):
fault bucket 719312874, type 5
event name: powershell
response: not available
cab id: 0
problem signature:
p1: powershell.exe
p2: 6.1.7600.16385
p3: system.objectdisposedexception
p4: system.objectdisposedexception
p5: tomation.remoting.outofprocesstextwriter.writeline
p6: system.io.filestream.write
p7: unknown
p8:
p9:
p10:
attached files:
these files may available here:
c:\users\....\appdata\local\microsoft\windows\wer\reportarchive\critical_powershell.exe_a65abc5ad2a635c22972fb03226e33bdaa394b5_ec7f962d
analysis symbol:
rechecking solution: 0
report id: bf68830c-6aa3-11df-bcc8-0024810f0727
report status: 0
i not doing explicit i/o, not believe following lines have issue @ hand.
p5: tomation.remoting.outofprocesstextwriter.writeline
p6: system.io.filestream.write
the script written has been simplified find exact nature of problem. if run using "start /noexit" work, incurring footprint powershell.exe process every time gets invoked. won't work.
has else seen this? has else developed work-around? need call script sql server agent job, , using command line option have. help!
thanks, john
john;
as work around, try putting "exit" last line of script, , running "start /noexit" ...
karl
http://unlockpowershell.wordpress.com
[string]([regex]::matches("6b61726c6d69747363686b65406d742e6e6574",'(.{2})')|%{[char][convert]::toint32($_.value,16)})
Windows Server > Windows PowerShell
Comments
Post a Comment