Gwith

Need Help

May 7th, 2014
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 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 $ComputerName | Select-Object -Property id
  14. switch ($test)
  15. {
  16. 1 {$test = "The answer is 300"}
  17. 5096 {$test = "the answer is 5096"}
  18. 3 {$test = "the answer is 321"}
  19. default {"The answer is none"}
  20. }
  21.  
  22. $obj = [pscustomObject]@{
  23. $ComputerName = $computer
  24. Test = $test
  25.  
  26. }
  27.  
  28. }
  29. }
  30.  
  31. end{
  32.  
  33. Write-Host ("answer = $obj")
  34.  
  35. }
  36. }
  37.  
  38. test
Advertisement
Add Comment
Please, Sign In to add comment