Skip to content
2 changes: 1 addition & 1 deletion AD-SITE-Get-ADSiteInventory/Get-ADSiteInventory.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,4 @@
}#get-ADSiteServicesInfo

#get-ADSiteServicesInfo #| export-csv .\test.csv
Get-ADSiteInventory
#Get-ADSiteInventory
53 changes: 53 additions & 0 deletions Help.Tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
$scripts = Get-ChildItem -Path $PSScriptRoot -Recurse -Filter *.ps1 |
Where-Object FullName -NotMatch '.Tests.'

[regex]$regex = "(^[A-Z\-]+-)"

Describe -Tag 'Help' 'Help' {

foreach ($script in $scripts) {

Context "[$($script.BaseName)] Validate Comment Based Help" {

# Correct name where file name does not match function name
if ($script.Name -Match $regex) {
$name = $script.BaseName.Replace($Matches[0], '')
} elseif ($script.Name -match 'O365-') {
$name = $script.BaseName.Replace($Matches[0], '')
} elseif ($script.Name -match 'Function_Template.ps1') {
$name = 'Get-Something'
} else {
$name = $script.BaseName
}

# Only process functions and not scripts
if ((Get-Content -Path $script.FullName -TotalCount 1) -match 'function') {

# Dot Source script
. $($script.FullName)

$functionHelp = Get-Help $name -Full

It 'Contains Description' {
$functionHelp.Description | Should Not BeNullOrEmpty
}

It 'Contains Synopsis' {
$functionHelp.Synopsis | Should Not BeNullOrEmpty
}

It 'Contains Examples' {
$functionHelp.Examples | Should Not BeNullOrEmpty
}

It 'Contains Parameters' {
$functionHelp.Parameters | Should Not BeNullOrEmpty
}
} else {
It "[$($script.BaseName)] is not a function and skipped" {
} -Skip
}
}
}
}