strange function behavior


 

the return in function doesn't work expect: function not return value "return", return information printed in function. it's hard debug when print info in the function when added print, treated part of returned value 

 

function a{

  "333"

  "called"

   return 1

}

 

$b=a

 

 

no output in console when run it

 

function a{

  "333"

  "called"

   return 1

}

 

$b=a

$b

 

$b is

333

called

1

 

 

weird thing, need care it

anything don't 'capture' inside function (assign variable or suppress output) returned function.for more information type in console:

help about_return

 

also, there's excellent blog post mvp keith hill topic:

effective powershell item 7: understanding "output"


shay levy [mvp]
http://blogs.microsoft.co.il/blogs/scriptfanatic
powershell toolbar


Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

Motherboard replacement

Cannot create Full Text Search catalog after upgrading to V12 - Database is not fully started up or it is not in an ONLINE state

Remote Desktop App - Error 0x207 or 0x607