Guest User

Untitled

a guest
May 21st, 2018
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. Function ListRunningServices
  2. {
  3. $services+= Get-Service | ?{$_.Status -eq "Running"} | sort Name | select Name;
  4. }
  5.  
  6. $services = @();
  7. ListRunningServices;
  8. $services;
  9.  
  10. Function ListRunningServices {
  11. Get-Service | ?{$_.Status -eq "Running"} | sort Name | select Name
  12. }
  13.  
  14. $services = ListRunningServices
  15. $services
  16.  
  17. Function ListRunningServices {
  18. $global:services = Get-Service | ?{$_.Status -eq "Running"} | sort Name | select Name
  19. }
  20.  
  21. $services = @()
  22. ListRunningServices
  23. $services
  24.  
  25. Function ListRunningServices
  26. {
  27. Get-Service | ?{$_.Status -eq "Running"} | sort Name | select Name |
  28. ForEach-Object {$services.add($_)}
  29. }
  30.  
  31. $services = New-Object collections.arraylist
  32. ListRunningServices
  33. $services
  34.  
  35. Function ListRunningServices
  36. {
  37. $services = @()
  38. $services+= Get-Service | ?{$_.Status -eq "Running"} | sort Name | select Name;
  39. return $services
  40. }
  41.  
  42.  
  43. $services = ListRunningServices
  44. $services
  45.  
  46. Function ListRunningServices
  47. {
  48. $global:services+= Get-Service | ?{$_.Status -eq "Running"} | sort Name | select Name;
  49. }
  50.  
  51. $services = @();
  52. ListRunningServices;
  53. $services;
  54.  
  55. # Visible everywhere inside the script file (f.ex: myNameScript.ps1)
  56. $script:names = @()
  57.  
  58. Function AddStringToArray ([string]$i_name) {
  59. $script:nam += $i_name
  60. }
  61.  
  62. AddStringToArray -i_name "Markie"
  63. AddStringToArray -i_name "Harry"
Add Comment
Please, Sign In to add comment