diff --git a/CHANGELOG.md b/CHANGELOG.md index 52d21f1..977c75b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ Which is based on [Keep A Changelog](http://keepachangelog.com/) ## [Unreleased] +### Added +- check-windows-directory.ps1, added plugin to check if a directory exist (@patricewhite). + ## [2.7.0] - 2018-05-09 ### Changed - check-windows-event-log.ps1, added plugin to check for pattern and returns the number criticals and warnings that match that pattern (@patricewhite) diff --git a/README.md b/README.md index 999d019..3c5c0f3 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,7 @@ These files provide basic Checks and Metrics for a Windows system. * bin/powershell/metric-windows-processor-queue-length.ps1 * bin/powershell/metric-windows-ram-usage.ps1 * bin/powershell/metric-windows-uptime.ps1 + * bin/powershell/check-windows-directory.ps1 * bin/powershell/check-windows-event-log.ps1 * bin/powershell/check-windows-log.ps1 diff --git a/bin/powershell/check-windows-directory.ps1 b/bin/powershell/check-windows-directory.ps1 new file mode 100644 index 0000000..83df601 --- /dev/null +++ b/bin/powershell/check-windows-directory.ps1 @@ -0,0 +1,33 @@ +<# +.SYNOPSIS + Checks if directory exist +.DESCRIPTION + Checks if directory exist +.Notes + FileName : check-windows-directory.ps1 + Author : Patrice White - patrice.white@ge.com +.LINK + https://github.com/sensu-plugins/sensu-plugins-windows +.PARAMETER LogName + Required. The name of the directory. + Example -Dir C:\Users\dir +.EXAMPLE + powershell.exe -file check-windows-directory.ps1 -Dir C:\Users\dir +#> + +[CmdletBinding()] +Param( + [Parameter(Mandatory=$True)] + [string]$Dir +) + +$ThisDir = Test-Path -Path $Dir + +#Shows diretory if it exist +if ($ThisDir) { + "CheckDirectory OK: Directory exist" + EXIT 0 +}else { + "CheckDirectory CRITICAL: Directory doesn't exist" + EXIT 2 +}