Private/Test-SpecPS1Extension.ps1
function Test-SpecPS1Extension { <# .SYNOPSIS This function tests if a file path has a .ps1 extension. .DESCRIPTION The Test-SpecPS1Extension function checks if a given file path has a .ps1 extension (case-insensitive). If the file path ends with ".ps1", it returns $true; otherwise, it returns $false. .PARAMETER filePath Specifies the file path to be tested for the .ps1 extension. .EXAMPLE $extensionTest = Test-SpecPS1Extension -filePath "C:\Scripts\MyScript.ps1" Returns: $true Tests whether the file path "C:\Scripts\MyScript.ps1" ends with the .ps1 extension and returns $true. .EXAMPLE $extensionTest = Test-SpecPS1Extension -filePath "D:\ProgramFiles\Tool.exe" Returns: $false Tests whether the file path "D:\ProgramFiles\Tool.exe" ends with the .ps1 extension and returns $false. .NOTES Author: owen.heaume Date: August 10, 2023 Version: 1.0 #> [cmdletbinding()] param ( [string]$filePath ) if ($filePath.EndsWith(".ps1", [System.StringComparison]::InvariantCultureIgnoreCase)) { Write-Verbose "File path ends with .ps1 extension." return $true } else { Write-Verbose "File path does not end with .ps1 extension." return $false } } |