Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get-ADSIComputer $ComputerName #15

Open
lazywinadmin opened this issue Nov 1, 2016 · 1 comment
Open

Get-ADSIComputer $ComputerName #15

lazywinadmin opened this issue Nov 1, 2016 · 1 comment
Labels

Comments

@lazywinadmin
Copy link
Owner

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 ''.
At line:1 char:1

  • Get-AdsiComputer $env:COMPUTERNAME
  •   + CategoryInfo          : InvalidArgument: (:) [Get-ADSIComputer], ParameterBindingException
      + FullyQualifiedErrorId : PositionalParameterNotFound,Get-ADSIComputer
    
@Get-Ryan
Copy link

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")])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants