get-textFromInput | Returns a text. If the parameter is clipboard, it returns the content of the clipboard. If it is a path of a file, it returns the file's content. Otherwise, it returns the value of the parameter itself. |
set-strictMode -version 3
function get-textFromInput {
param (
[string] $param
)
if ($param -eq 'clipboard') {
return get-clipboard
}
$param_ = $param -replace '^\w:', '' # remove leading C: etc. because the colon is an illegal character
# Check if $param_ contains characters that are illegal in NTFS:
if ( $param_ -ne '/' -and $param_ -notMatch '[?\*:<>|"\n]') {
if (test-path -pathType leaf -literalPath $param) {
return get-content -raw $param
}
}
return $param
}
@{
rootModule = 'psHelpers.psm1'
moduleVersion = '2026.09.30'
author = 'René Nyffenegger'
description = 'Uncategorized utility functions'
functionsToExport = @(
'get-textFromInput'
)
guid = '52656e65-7073-4865-6C70-657273729af3'
}