Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 12th, 2012  |  syntax: None  |  size: 0.64 KB  |  hits: 7  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Different code depending on computer name. Most efficient process?
  2. $a = hostname
  3. switch ($a)
  4.     {
  5.         "WS001" { $sb = {dir} ; $txt = "Computer name: " + $a  }
  6.         "WS003" { $sb = { get-process } ; $txt = "Computer name: " + $a }
  7.  
  8.         default { $sb = $null ;  $txt = "This Computer can't run this script"}        
  9.     }
  10.  
  11. if ($sb) { &$sb }
  12. $txt
  13.        
  14. $a = hostname
  15. switch ($a)
  16.     {
  17.         "WS001" { $sb = {dir} ; $txt = "Computer name: " + $a ; break }
  18.         "WS003" { $sb = { get-process } ; $txt = "Computer name: " + $a; break }
  19.  
  20.         default { $sb = $null ;  $txt = "This Computer can't run this script"}        
  21.     }
  22. ...