*Remark* this is a post to test Live Writer so it will change a couple of times. (*Edit 5 *for now it looks good I can edit my posts without losing formatting, and offline)
*Edit 2* there will be some double posts for testing, I will remove those later (this link will stay others will be removed)
In the last post you did see that I used the verbose-switch
here I will show an example on how to set this for the function itself, or to use the preference variables to set this:
*Edit* note that all the Write Messages do not get passed to the pipeline so only will display on the host.
*see this examples in normal text look if pipeline chars do stay
PoSH>$test = "pipeline" ; write-host "Host"
HostPoSH>$test
pipelinePoSH>1,2 |% {out-host "pipeline $_" ; write-host "Host $_"}
Host 1
Host 2PoSH>1,2 |% {"pipeline $_" ; write-host "Host $_"}
pipeline 1
Host 1
pipeline 2
Host 2PoSH>1,2 |% {"pipeline $_" ; write-host "Host $_"} |% {"second foreach : $_"}
second foreach : pipeline 1
Host 1
second foreach : pipeline 2
Host 2
PoSH>
*End Edit*
In the former examples you could see what is the difference between outputting to the host and to the pipeline, the last example shows that in the second foreach there is only the output from out-object (out-object is used by default if you just put a string on a line as I did in the example)
an example how to add a switch to a funtion, so you can override it for a function like you can with a CMDlet :
now you can change the behavior by setting the preference in the $global scope or overrule it on a Function base this like this :
*Edit 4 *Note that the -verbose switch will set it only for the script it leaves the global setting alone
Enjoy,
Greetings, /\/\o\/\/
Tags : Monad msh PowerShell
October 2005 November 2005 December 2005 January 2006 February 2006 March 2006 April 2006 May 2006 June 2006 July 2006 August 2006 September 2006 October 2006 November 2006 December 2006