Gwith

Attempt at advanced function

May 6th, 2014
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. function test{
  2. param(
  3. [string[]]$ComputerName = 'localhost'
  4. )
  5.  
  6. begin{
  7.  
  8. }
  9.  
  10. process{
  11. ForEach ($Computer in $ComputerName){
  12.  
  13. $test = Get-Process -name explorer -ComputerName $Computer | Select-Object -Property id
  14. switch ($test)
  15. {
  16. 300 {$test = "The answer is 300"}
  17. 5096 {$test = "the answer is 5096"}
  18. 321 {$test = "the answer is 321"}
  19. default {"The answer is none"}
  20. }
  21. }
  22. }
  23.  
  24. end{
  25.  
  26. Write-Host ("answer = $test")
  27.  
  28. }
  29. }
  30.  
  31. test
Advertisement
Add Comment
Please, Sign In to add comment