Advertisement
Guest User

Untitled

a guest
Sep 28th, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1.  
  2. Describe 'My process checks' {
  3.  
  4. Context 'Checking essential Windows processes are running' {
  5.  
  6. It 'winlogon.exe is running' {
  7. get-process -Name 'winlogon' | Should be $true
  8. }
  9.  
  10. }
  11.  
  12. $CPUThreshold = 10
  13.  
  14. Context "Checking for processes using > $CPUThreshold% CPU" {
  15.  
  16. $CpuCores = (Get-WMIObject Win32_ComputerSystem).NumberOfLogicalProcessors
  17. $Samples = (Get-Counter β€œ\Process(*)\% Processor Time” -ErrorAction SilentlyContinue).CounterSamples
  18. $Samples | Select InstanceName,@{Name=”CPU”;Expression={[Decimal]::Round(($_.CookedValue / $CpuCores), 2)}} `
  19. | Sort-Object InstanceName `
  20. | Where-Object {$_.InstanceName -ne "idle" -and $_.InstanceName -ne "_total"} `
  21. | ForEach-Object {
  22.  
  23. It "Process $($_.InstanceName) is using $($_.CPU)% CPU" {
  24. $_.CPU | Should Not BeGreaterThan 10
  25. }
  26.  
  27. }
  28. }
  29.  
  30. }
  31.  
  32. Describe 'Weird science checks' {
  33.  
  34. Context 'Checking for the impossible' {
  35.  
  36. It 'It should be opposite day' {
  37. $true | Should be $false
  38. }
  39.  
  40. }
  41. }
  42.  
  43. Describe 'Day of the week check' {
  44.  
  45. $WeekDays = "Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"
  46.  
  47. $WeekDays | ForEach-Object {
  48.  
  49. It "Today should be $_" {
  50. (get-date).DayOfWeek | Should be $_
  51. }
  52. }
  53. }
  54.  
  55. Describe 'Operating System check' {
  56.  
  57. It 'C:\Windows folder exists' {
  58. 'C:\Windows' | Should Exist
  59. }
  60.  
  61. It 'C:\Linux folder does not exist' {
  62. 'C:\Linux' | Should Not Exist
  63. }
  64.  
  65. }
  66.  
  67. Describe 'Windows service check' {
  68.  
  69. Get-Service -DisplayName "Windows*" | ForEach-Object {
  70.  
  71. It "The $($_.DisplayName) service should be running" {
  72. $_.Status | Should be 'Running'
  73. }
  74. }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement