Cash Talks - BS Walks RSS 2.0
# Sunday, 17 February 2008

This is a useful template for starting a CmdLet that needs to work in a PipeLine or by passing parameters.

 

Processing is implemented in the processItem sub-function.  All the “–ne $null” conditions handle the differences between pipeline and parameter invocation.

 

function Test-PipelineOrParm ($parm)

{

  begin

  {

    function processItem($item)

    {

      # Implement processing in this function

      "processItem $item"

    }

   

    if ($parm -ne $null)

    {

      foreach ($item in $parm)

      {

        "begin $(processItem $item)"

      }

    }

  }

  process

  {

    if ($_ -ne $null)

    {

      "process $(processItem $_)"

    }

  }

  end

  {

    Write-Host "Done"

  }

}

 

These two examples demonstrate calling the template.

 

Write-Host "Test Pipeline processing"

Get-ChildItem | Test-PipelineOrParm

 

Write-Host "Test Parm processing"

Test-PipelineOrParm $(Get-ChildItem)

 

Sunday, 17 February 2008 23:26:38 (GMT Standard Time, UTC+00:00)  #    Comments [74] -
Powershell
Tracked by:
"http://blastpr.com/wiki/js/pages/paxil/index.html" (http://blastpr.com/wiki/js/... [Pingback]
"http://morningside.edu/mics/_notes/pages/claritin/index.html" (http://morningsi... [Pingback]
"http://morningside.edu/mics/_notes/pages/wellbutrin/index.html" (http://morning... [Pingback]
"http://blastpr.com/wiki/js/pages/claritin/index.html" (http://blastpr.com/wiki/... [Pingback]
"http://blastpr.com/wiki/js/pages/rainbow-brite/index.html" (http://blastpr.com/... [Pingback]
"http://morningside.edu/mics/_notes/pages/prilosec/index.html" (http://morningsi... [Pingback]
"http://morningside.edu/mics/_notes/pages/accutane/index.html" (http://morningsi... [Pingback]
"http://blastpr.com/wiki/js/pages/hoodia/index.html" (http://blastpr.com/wiki/js... [Pingback]
"http://morningside.edu/mics/_notes/pages/rainbow-brite/index.html" (http://morn... [Pingback]
"http://blastpr.com/wiki/js/pages/nexium/index.html" (http://blastpr.com/wiki/js... [Pingback]
"http://morningside.edu/mics/_notes/pages/viagra/index.html" (http://morningside... [Pingback]
"http://blastpr.com/wiki/js/pages/melatonin/index.html" (http://blastpr.com/wiki... [Pingback]
"http://blastpr.com/wiki/js/pages/ultram/index.html" (http://blastpr.com/wiki/js... [Pingback]
"http://morningside.edu/mics/_notes/pages/coumadin/index.html" (http://morningsi... [Pingback]
"http://blastpr.com/wiki/js/pages/celexa/index.html" (http://blastpr.com/wiki/js... [Pingback]
"http://morningside.edu/mics/_notes/pages/lipitor/index.html" (http://morningsid... [Pingback]
"http://morningside.edu/mics/_notes/pages/paxil/index.html" (http://morningside.... [Pingback]
"http://morningside.edu/mics/_notes/pages/nexium/index.html" (http://morningside... [Pingback]
"http://morningside.edu/mics/_notes/pages/cialis/index.html" (http://morningside... [Pingback]
"http://morningside.edu/mics/_notes/pages/ultram/index.html" (http://morningside... [Pingback]
"http://morningside.edu/mics/_notes/pages/prozac/index.html" (http://morningside... [Pingback]
"http://morningside.edu/mics/_notes/pages/celexa/index.html" (http://morningside... [Pingback]
"http://blastpr.com/wiki/js/pages/viagra/index.html" (http://blastpr.com/wiki/js... [Pingback]
"http://morningside.edu/mics/_notes/pages/cymbalta/index.html" (http://morningsi... [Pingback]
"http://morningside.edu/mics/_notes/pages/lexapro/index.html" (http://morningsid... [Pingback]
"http://morningside.edu/mics/_notes/pages/melatonin/index.html" (http://mornings... [Pingback]
"http://blastpr.com/wiki/js/pages/cialis/index.html" (http://blastpr.com/wiki/js... [Pingback]
"http://blastpr.com/wiki/js/pages/prozac/index.html" (http://blastpr.com/wiki/js... [Pingback]
"http://blastpr.com/wiki/js/pages/lipitor/index.html" (http://blastpr.com/wiki/j... [Pingback]
"http://blastpr.com/wiki/js/pages/coumadin/index.html" (http://blastpr.com/wiki/... [Pingback]
"http://blastpr.com/wiki/js/pages/synthroid/index.html" (http://blastpr.com/wiki... [Pingback]
"http://blastpr.com/wiki/js/pages/lexapro/index.html" (http://blastpr.com/wiki/j... [Pingback]
"http://morningside.edu/mics/_notes/pages/tramadol/index.html" (http://morningsi... [Pingback]
"http://morningside.edu/mics/_notes/pages/celebrex/index.html" (http://morningsi... [Pingback]
"http://pddownloads.com/docs/94929363/index.html" (http://pddownloads.com/docs/9... [Pingback]
"http://islands-croatia.comislands-croatia.com/includes/js/docs/87090382/index.h... [Pingback]
"http://promocija.com.hr/promocija.com.hr/includes/js/docs/37348396/index.html" ... [Pingback]
"http://martinrozon.com/images/photos/docs/54373182/index.html" (http://martinro... [Pingback]
"http://islands-croatia.comislands-croatia.com/includes/js/docs/82710340/index.h... [Pingback]
"http://promocija.com.hr/promocija.com.hr/includes/js/docs/52060005/index.html" ... [Pingback]
"http://legambitdufou.org/Library/docs/15090396/index.html" (http://legambitdufo... [Pingback]
"http://ipsilon.hr/ipsilon.hr/cms/4/lib/docs/55227677/index.html" (http://ipsilo... [Pingback]
"http://temerav.com/images/menu/20420171/index.html" (http://temerav.com/images/... [Pingback]
"http://split-dalmatia.com/split-dalmatia.com/images/docs/84431573/index.html" (... [Pingback]
"http://witze-humor.de/templates/images/docs/69259068/index.html" (http://witze-... [Pingback]
"http://thebix.com/includes/compat/docs/15870923/index.html" (http://thebix.com/... [Pingback]
"http://witze-humor.de/templates/images/docs/83157240/index.html" (http://witze-... [Pingback]
"http://pddownloads.com/docs/08296030/index.html" (http://pddownloads.com/docs/0... [Pingback]
"http://swellhead.netswellhead.net/docs/92808772/index.html" (http://swellhead.n... [Pingback]
"http://swellhead.netswellhead.net/docs/84545083/index.html" (http://swellhead.n... [Pingback]
"http://realestate.hr/templates/css/docs/36157459/index.html" (http://realestate... [Pingback]
"http://islands-croatia.comislands-croatia.com/includes/js/docs/68291686/index.h... [Pingback]
"http://vladan.strigo.net/wp-includes/js/docs/25746442/index.html" (http://vlada... [Pingback]
"http://lecouac.org/ecrire/lang/docs/25282359/index.html" (http://lecouac.org/ec... [Pingback]
"http://temerav.com/images/menu/91084644/index.html" (http://temerav.com/images/... [Pingback]
"http://seo4u.at/images/docs/72359352/index.html" (http://seo4u.at/images/docs/7... [Pingback]
"http://promocija.com.hr/promocija.com.hr/includes/js/docs/63224938/index.html" ... [Pingback]
"http://temerav.com/images/menu/96509501/index.html" (http://temerav.com/images/... [Pingback]
"http://martinrozon.com/images/photos/docs/56637999/index.html" (http://martinro... [Pingback]
"http://promocija.com.hr/promocija.com.hr/includes/js/docs/48335156/index.html" ... [Pingback]
"http://jivest2006.com/docs/42940613/index.html" (http://jivest2006.com/docs/429... [Pingback]
"http://vladan.strigo.net/wp-includes/js/docs/04726190/index.html" (http://vlada... [Pingback]
"http://thejohnslater.com/pix/img/docs/42082955/index.html" (http://thejohnslate... [Pingback]
"http://thebix.com/includes/compat/docs/44694113/index.html" (http://thebix.com/... [Pingback]
"http://plantmol.com/docs/24471383/index.html" (http://plantmol.com/docs/2447138... [Pingback]
"http://entartistes.ca/images/images/docs/28212733/index.html" (http://entartist... [Pingback]
"http://discussgod.com/cpstyles/docs/90092602/index.html" (http://discussgod.com... [Pingback]
"http://legambitdufou.org/Library/docs/28049195/index.html" (http://legambitdufo... [Pingback]
"http://thebix.com/includes/compat/docs/51589391/index.html" (http://thebix.com/... [Pingback]
"http://islands-croatia.comislands-croatia.com/includes/js/docs/60974094/index.h... [Pingback]
"http://temerav.com/images/menu/05559064/index.html" (http://temerav.com/images/... [Pingback]
"http://ncdtnanotechportal.info/generator/docs/87198700/index.html" (http://ncdt... [Pingback]
"http://martinrozon.com/images/photos/docs/75270452/index.html" (http://martinro... [Pingback]
"http://thejohnslater.com/pix/img/docs/41914710/index.html" (http://thejohnslate... [Pingback]
"http://lecouac.org/ecrire/lang/docs/20007231/index.html" (http://lecouac.org/ec... [Pingback]
"http://discussgod.com/cpstyles/docs/62161481/index.html" (http://discussgod.com... [Pingback]
"http://lecouac.org/ecrire/lang/docs/49649526/index.html" (http://lecouac.org/ec... [Pingback]
"http://temerav.com/images/menu/46200403/index.html" (http://temerav.com/images/... [Pingback]
"http://legambitdufou.org/Library/docs/04618667/index.html" (http://legambitdufo... [Pingback]
"http://sevainc.com/bad_denise/img/2/cialis/" (http://sevainc.com/bad_denise/img... [Pingback]
"http://easytravelcanada.info/js/pages/6/lipitor/" (http://easytravelcanada.info... [Pingback]
"http://sevainc.com/bad_denise/img/6/lexapro/" (http://sevainc.com/bad_denise/im... [Pingback]
"http://sevainc.com/bad_denise/img/10/synthroid/" (http://sevainc.com/bad_denise... [Pingback]
"http://sevainc.com/bad_denise/img/12/wellbutrin/" (http://sevainc.com/bad_denis... [Pingback]
"http://easytravelcanada.info/js/pages/12/zoloft/" (http://easytravelcanada.info... [Pingback]
"http://sevainc.com/bad_denise/img/5/effexor/" (http://sevainc.com/bad_denise/im... [Pingback]
"http://easytravelcanada.info/js/pages/11/tramadol/" (http://easytravelcanada.in... [Pingback]
"http://simplecanada.info/js/pages/13912893/" (http://simplecanada.info/js/pages... [Pingback]
"http://easytravelcanada.info/js/pages/12/wellbutrin/" (http://easytravelcanada.... [Pingback]
"http://easytravelcanada.info/js/pages/5/hoodia/" (http://easytravelcanada.info/... [Pingback]
"http://sevainc.com/bad_denise/img/11/ultram/" (http://sevainc.com/bad_denise/im... [Pingback]
"http://jemnemelodierecords.sk/img/viagra/" (http://jemnemelodierecords.sk/img/v... [Pingback]
"http://easytravelcanada.info/js/pages/4/cymbalta/" (http://easytravelcanada.inf... [Pingback]
"http://easytravelcanada.info/js/pages/1/accutane/" (http://easytravelcanada.inf... [Pingback]
"http://inatelevizia.sk/ad/img/viagra/" (http://inatelevizia.sk/ad/img/viagra/) [Pingback]
"http://easytravelcanada.info/js/pages/8/prilosec/" (http://easytravelcanada.inf... [Pingback]
"http://adventure-traveling.com/images/img/viagra/" (http://adventure-traveling.... [Pingback]
"abaffy.org/la/img/viagra/" (abaffy.org/la/img/viagra/) [Pingback]
"http://sevainc.com/bad_denise/img/1/accutane/" (http://sevainc.com/bad_denise/i... [Pingback]
"http://easytravelcanada.info/js/pages/11/ultram/" (http://easytravelcanada.info... [Pingback]
"http://sevainc.com/bad_denise/img/4/cymbalta/" (http://sevainc.com/bad_denise/i... [Pingback]
"http://sevainc.com/bad_denise/img/12/viagra/" (http://sevainc.com/bad_denise/im... [Pingback]
"http://sevainc.com/bad_denise/img/7/nexium/" (http://sevainc.com/bad_denise/img... [Pingback]
"http://abaffydesign.com/la/img/cialis/" (http://abaffydesign.com/la/img/cialis/... [Pingback]
"http://easytravelcanada.info/js/pages/12/viagra/" (http://easytravelcanada.info... [Pingback]
"abaffy.org/la/img/cialis/" (abaffy.org/la/img/cialis/) [Pingback]
"http://abaffydesign.com/la/img/viagra/" (http://abaffydesign.com/la/img/viagra/... [Pingback]
"http://sevainc.com/bad_denise/img/7/melatonin/" (http://sevainc.com/bad_denise/... [Pingback]
"http://easytravelcanada.info/js/pages/6/lexapro/" (http://easytravelcanada.info... [Pingback]
"http://sevainc.com/bad_denise/img/3/clomid/" (http://sevainc.com/bad_denise/img... [Pingback]
"http://gatewayplayhouse.com/photos/cai/pages/35807953/milking-tits-escorts.html... [Pingback]
"http://gatewayplayhouse.com/photos/cai/pages/35807953/ravon-nude.html" (http://... [Pingback]
"http://odin.net/images/pages/35694472/bikini-calenders.html" (http://odin.net/i... [Pingback]
"http://gatewayplayhouse.com/photos/cai/pages/35807953/nude-sleeping-sex-xxx.htm... [Pingback]
"http://cidesi.com/images/metro/metro2/pages/99493954/nauty-celebritys-having-se... [Pingback]
"http://gatewayplayhouse.com/photos/cai/pages/53348735/adult-bib.html" (http://g... [Pingback]
"http://gatewayplayhouse.com/photos/cai/pages/53348735/ametuer-zoo-girls.html" (... [Pingback]
"http://odin.net/images/pages/52807681/sex-as-a-suspect-classification.html" (ht... [Pingback]
"http://gatewayplayhouse.com/photos/cai/pages/53348735/agent-scully-alien-fuck.h... [Pingback]
"http://cidesi.com/images/metro/metro2/pages/99493954/baby-pool.html" (http://ci... [Pingback]
"http://odin.net/images/pages/35694472/downloadable-porn-videos.html" (http://od... [Pingback]
"http://gatewayplayhouse.com/photos/cai/pages/35807953/little-match-girl-story.h... [Pingback]
"http://odin.net/images/pages/35694472/small-tit-teens-tgp.html" (http://odin.ne... [Pingback]
"http://gatewayplayhouse.com/photos/cai/pages/53348735/porn-star-brooke-banner.h... [Pingback]
"http://gatewayplayhouse.com/photos/cai/pages/35807953/xxx-asian-anal-milf-free.... [Pingback]
"http://odin.net/images/pages/35694472/candace-von-fuck.html" (http://odin.net/i... [Pingback]
"http://odin.net/images/pages/52807681/best-adult-chat-program.html" (http://odi... [Pingback]
"http://cidesi.com/images/metro/metro2/pages/99493954/erotic-comic-archives.html... [Pingback]
"http://cidesi.com/images/metro/metro2/pages/32162341/xpress-train-hentai-movie.... [Pingback]
"http://cidesi.com/images/metro/metro2/pages/99493954/lisa-rowe-girl-interrupted... [Pingback]
"http://odin.net/images/pages/35694472/having-sex-while-pregnant.html" (http://o... [Pingback]
"http://cidesi.com/images/metro/metro2/pages/99493954/erotic-literature-for-wome... [Pingback]
"http://cidesi.com/images/metro/metro2/pages/99493954/adult-porn-comic.html" (ht... [Pingback]
"http://gatewayplayhouse.com/photos/cai/pages/53348735/virgin-vagina-pic.html" (... [Pingback]
"http://odin.net/images/pages/52807681/webcams-for-couples.html" (http://odin.ne... [Pingback]
"http://cidesi.com/images/metro/metro2/pages/99493954/chyna-porn-movie.html" (ht... [Pingback]
"http://cidesi.com/images/metro/metro2/pages/32162341/dress-up-online-games-for-... [Pingback]
"http://cidesi.com/images/metro/metro2/pages/32162341/sexual-xxx-stories.html" (... [Pingback]
"http://gatewayplayhouse.com/photos/cai/pages/35807953/adult-synchronized-skate-... [Pingback]
"http://cidesi.com/images/metro/metro2/pages/99493954/adult-free-gay-porn.html" ... [Pingback]
"http://gatewayplayhouse.com/photos/cai/pages/53348735/barbue-girl.html" (http:/... [Pingback]
"http://odin.net/images/pages/35694472/council-of-adult-education-australia.html... [Pingback]
"http://odin.net/images/pages/52807681/ymca-baby-sitting-classes.html" (http://o... [Pingback]
"http://odin.net/images/pages/52807681/naruto-hentai.html" (http://odin.net/imag... [Pingback]
"http://odin.net/images/pages/52807681/hidden-sex-cameras.html" (http://odin.net... [Pingback]
"http://gatewayplayhouse.com/photos/cai/pages/35807953/tylene-buck-bikini-movies... [Pingback]
"http://odin.net/images/pages/52807681/life-teen-mass-balboa.html" (http://odin.... [Pingback]
"http://odin.net/images/pages/35694472/index.html" (http://odin.net/images/pages... [Pingback]
"http://cidesi.com/images/metro/metro2/pages/32162341/sex-toys-oregon.html" (htt... [Pingback]
"http://odin.net/images/pages/35694472/hot-mom-pics.html" (http://odin.net/image... [Pingback]
"http://gatewayplayhouse.com/photos/cai/pages/53348735/free-erotic-lesbian-video... [Pingback]
"http://cidesi.com/images/metro/metro2/pages/32162341/free-trial-xxx-incest-site... [Pingback]
"http://gatewayplayhouse.com/photos/cai/pages/35807953/nude-celeb-thumbs.html" (... [Pingback]
"http://odin.net/images/pages/52807681/golden-butterfly-poker-vibrator-china.htm... [Pingback]
"http://cidesi.com/images/metro/metro2/pages/32162341/girls-that-lick-ass.html" ... [Pingback]
"http://odin.net/images/pages/35694472/free-adult-sex-classifieds-china.html" (h... [Pingback]
"http://odin.net/images/pages/52807681/sex-women-muscle.html" (http://odin.net/i... [Pingback]
"http://cidesi.com/images/metro/metro2/pages/99493954/spanish-escorts-es.html" (... [Pingback]
"http://cidesi.com/images/metro/metro2/pages/99493954/mmf-free-sex-sites.html" (... [Pingback]
"http://odin.net/images/pages/35694472/janet-jackson-bikini.html" (http://odin.n... [Pingback]
"http://cidesi.com/images/metro/metro2/pages/99493954/fuck-bitches-get-money-lyr... [Pingback]
Archive
<2008 February>
SunMonTueWedThuFriSat
272829303112
3456789
10111213141516
17181920212223
2425262728291
2345678
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2017
Cash Foley
Sign In
Statistics
Total Posts: 20
This Year: 0
This Month: 0
This Week: 0
Comments: 5413
Themes
Pick a theme:
All Content © 2017, Cash Foley
DasBlog theme 'Business' created by Christoph De Baene (delarou)