keyongtech


  keyongtech > windows.* > windows.powershell

 #1  
07-28-08, 11:26 PM
AHartman
If you run your script like this:



powershell -command "& {C:\Path of PS1 file\FileName.ps1}"



can you check the return code of that execution?


Thanks.
 #2  
07-29-08, 12:38 AM
Marco Shaw [MVP]
AHartman wrote:
> If you run your script like this:
>>

> powershell -command "& {C:\Path of PS1 file\FileName.ps1}"
>>

> can you check the return code of that execution?
>> Thanks.


Check this blog for a tip:
http://dmitrysotnikov.wordpress.com/...-availability/

Marco
 #3  
07-29-08, 01:00 AM
Alex K. Angelopoulos
The only way to do this is to process the output returned by the command.
Assuming you are running from Cmd.exe, PowerShell does not set an errorlevel
on exit - probably because it's difficult to map the results of a PS
operation into a single flat error code, since the internal standard is
error objects. If you're running PowerShell within PowerShell, however, the
$? variable will be $false if errors were encountered and $true if not.

One potential workaround is to get the output in XML format and then have an
XML processing tool parse it. I suspect that's way beyond what will be
practical for you, though. : s


"AHartman" <Hoosbruin> wrote in message
news:nz2d
[..]
 #4  
07-29-08, 01:05 AM
Alex K. Angelopoulos
Doh! Ignore me. I completely forgot that you could use exit $LASTEXITCODE as
Marco's link points out.

"Alex K. Angelopoulos" <aka(at)mvps.org> wrote in message
news:5596
[..]
Similar Threads
Thread Thread Starter
Data shape command text contains a syntax error at or near position 106 in the command.

2007 .adp front ends connected to SQL 2005. I frequently run into this when users are drilling into data on a DataSheet form. They may filter on a value in one column and...

Bob
autorun.inf - shell\..\command with command line parameter doesn'twork

Below a piece of my autorun.inf file I have problems with: shell\slides00 = slides '&slideshow all' shell\slides00\command = _Tools_\XnView\xnview.exe...

kakii
howto count differrent command fields on lsof command (newbie question)

Hello all, first let me apologize if you find this question too stupid to post it to this group :-) I have some problem with swap space utilization and for this reason...

NoE
Newbi Question - what is the command line command for launching the file explorer on RH Linux?

Hi, This is a newbi question. Can some one please tell me the command line command for launching the file explorer on RH Linux? Thanks, T.

L
command object command throws error after windows NT to win2k migration

My company has four web servers running copies of same ASP web application. One of the servers is running on windows 2000 Advanced server edition (without service pack) ,...

Ramachandran Balasubramaniam

Privacy Policy | All times are GMT. The time now is 05:47 PM.

Merging Information Logo
[Deutschland] [Espaņa] [France] [Italia] [Nederland] [Polska] [United Kingdom]