Can someone tell me, why this function call does not work and why the argument is always empty ?
function check([string]$input){
Write-Host $input #empty line
$count = $input.Length #always 0
$test = ([ADSI]::Exists('WinNT://./'+$input)) #exception (empty string)
return $test
}
check 'test'
Trying to get the info if an user or usergroup exists..
Best regards
$input
is an automatic variable.
https://technet.microsoft.com/ru-ru/library/hh847768.aspx
$Input
Contains an enumerator that enumerates all input that is passed to a function. The
$input
variable is available only to functions and script blocks (which are unnamed functions). In the Process block of a function, the$input
variable enumerates the object that is currently in the pipeline. When the Process block completes, there are no objects left in the pipeline, so the$input
variable enumerates an empty collection. If the function does not have a Process block, then in the End block, the$input
variable enumerates the collection of all input to the function.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With