Creating a function with boundparameters, I don't know what's wrong.


i don't know if brain messed but, can't work. whenever write:

read-text "test"

or

read-text -fore yellow "test"

it's printing following:

if ($fore)  {      [void]$psboundparameters.remove("fore")      [console]::foregroundcolor = $fore      read-host $psboundparameters      [console]::resetcolor()  }  else  {      read-host $psboundparameters  }

here's module, i'm importing, before running script:

#read-text    #you can give read-host command color instead of white function.    #example:  #read-text -fore yellow "type something"    #you can still save variable:  #$a = read-host -fore yellow "type something"  #write-host $a    function read-text   {      param($fore)      {          if ($fore)          {              [void]$psboundparameters.remove("fore")              [console]::foregroundcolor = $fore              read-host $psboundparameters              [console]::resetcolor()          }          else          {              read-host $psboundparameters          }      }  }


the following signature:

powershell programmer & advanced lua programmer

location: switzerland

beside that, whenever see reply, think helpful, click "vote helpful"! , whenever see reply being answer main question of thread, click "mark answer" (if opened thread).

i published url's icons in signature.

please contact me, before reporting me, thank you.

[string](0..21|%{[char][int]([int]("{0:d}" -f 0x28)+('577076797174-87661607769657424-8687168065964').substring(($_*2),2))})-replace' '

this technic called splatting!
see here: http://technet.microsoft.com/en-us/magazine/gg675931.aspx

please click “mark answer” if post answers question , click “vote helpful” if post helps you.
bitte markiere hilfreiche beiträge von mir als “als hilfreich bewerten” und beiträge die deine frage ganz oder teilweise beantwortet haben als “als antwort markieren”.
powershell blog http://www.admin-source.info
[string](0..21|%{[char][int]([int]("{0:d}" -f 0x28)+('755964655967-86965747271757624-8796158066061').substring(($_*2),2))})-replace' '
german ? come german powershell forum!



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

some help on Event 540

WMI Repository 4GB limit - Win 2003 Ent Question

Event ID 1302 (error 1307) DFS replication service encountered an error while writing to the debug log file