Public/Get-SpecFullPath.ps1
function Get-SpecFullPath { param ( [string]$psScript, [string]$psscriptPath, [string]$exe, [string]$exePath ) # if all params are empty... if ([string]::IsNullOrEmpty($psScript) -and [string]::IsNullOrEmpty($psscriptPath) -and [string]::IsNullOrEmpty($exe) -and [string]::IsNullOrEmpty($exePath)) { Write-verbose "All parameters are empty." return 501 } # if all params are used... if (-not[string]::IsNullOrEmpty($psScript) -and -not[string]::IsNullOrEmpty($psscriptPath) -and -not[string]::IsNullOrEmpty($exe) -and -not[string]::IsNullOrEmpty($exePath)) { Write-verbose "All parameters are empty." return 502 } # Check if the string has a trailing backslash and remove it if present if ($psscriptpath.EndsWith('\')) { $psscriptpath = $psscriptpath.TrimEnd('\') } if ($exepath.EndsWith('\')) { $exepath = $exepath.TrimEnd('\') } # construct the full path, depending on if it is a .ps1 or .exe if (-not [string]::IsNullOrEmpty($psscript)) { return "$($psscriptPath)\$($psscript)" } else { return "$($exePath)\$($exe)" } } |