Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Describe 'My process checks' {
- Context 'Checking essential Windows processes are running' {
- It 'winlogon.exe is running' {
- get-process -Name 'winlogon' | Should be $true
- }
- }
- $CPUThreshold = 10
- Context "Checking for processes using > $CPUThreshold% CPU" {
- $CpuCores = (Get-WMIObject Win32_ComputerSystem).NumberOfLogicalProcessors
- $Samples = (Get-Counter β\Process(*)\% Processor Timeβ -ErrorAction SilentlyContinue).CounterSamples
- $Samples | Select InstanceName,@{Name=βCPUβ;Expression={[Decimal]::Round(($_.CookedValue / $CpuCores), 2)}} `
- | Sort-Object InstanceName `
- | Where-Object {$_.InstanceName -ne "idle" -and $_.InstanceName -ne "_total"} `
- | ForEach-Object {
- It "Process $($_.InstanceName) is using $($_.CPU)% CPU" {
- $_.CPU | Should Not BeGreaterThan 10
- }
- }
- }
- }
- Describe 'Weird science checks' {
- Context 'Checking for the impossible' {
- It 'It should be opposite day' {
- $true | Should be $false
- }
- }
- }
- Describe 'Day of the week check' {
- $WeekDays = "Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"
- $WeekDays | ForEach-Object {
- It "Today should be $_" {
- (get-date).DayOfWeek | Should be $_
- }
- }
- }
- Describe 'Operating System check' {
- It 'C:\Windows folder exists' {
- 'C:\Windows' | Should Exist
- }
- It 'C:\Linux folder does not exist' {
- 'C:\Linux' | Should Not Exist
- }
- }
- Describe 'Windows service check' {
- Get-Service -DisplayName "Windows*" | ForEach-Object {
- It "The $($_.DisplayName) service should be running" {
- $_.Status | Should be 'Running'
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement