AdsiPS
AdsiPS copied to clipboard
Get-ADSIComputer $ComputerName
When using Get-ADSIComputer $ComputerName
I'm getting the following error
Get-AdsiComputer $env:COMPUTERNAME Get-ADSIComputer : A positional parameter cannot be found that accepts argument '<NAME OF COMPUTER>'. At line:1 char:1
- Get-AdsiComputer $env:COMPUTERNAME
-
+ CategoryInfo : InvalidArgument: (:) [Get-ADSIComputer], ParameterBindingException + FullyQualifiedErrorId : PositionalParameterNotFound,Get-ADSIComputer
The error is due to not listing a position for any of the parameters in the function. You mention in your guidelines to use explicit parameter names and not assume position, which is good, but if you don't have position set for any of the parameters, you prevent the use of your function without explicitly naming the parameters when calling it.
So you either need to always use named parameters:
Get-ADSIComputer -Identity $env:COMPUTERNAME
Or adjust the $Identity parameter line to allow it to accept positional input:
param ([Parameter(Mandatory=$true,Position=0,ParameterSetName="Identity")])