PositionalParameterNotFound

Hi All,

I get PositionalParameterNotFound error while executing the below code. Please help me.

$b = get-date "17-Feb-2020"Get-ADUser - filter {whenChanged - le $b} -Server "vsat.Kunder.com" -SearchBase "OU=TPA Accounts,OU=User Directory,DC=vsat,DC=kunder,DC=com" -Properties shellGGDComputerUserId,enabled,DN,whenChanged| Export-Csv C:\Apps\Data\VSAT.csv -Append (Get-ADUser - filter {whenChanged - le $b} -Server "vsat.kunder.com" -SearchBase "OU=TPA Accounts,OU=User Directory,DC=vsat,DC=kunder,DC=com" -Properties shellGGDComputerUserId |Select-Object shellGGDComputerUserId).count

 

Your code seems to be pasted all in one line. Can you paste the exact error here.
I can see two expression combined in single line and spaces between - and parameter name (- filter should be -filter).

Thanks for the reply. Here is the error message

Get-ADUser : A positional parameter cannot be found that accepts argument ‘-’.
At C:\Users\Santhosha.Kunder\Desktop\ICR application\vsat.ps1:2 char:2

  • (Get-ADUser - filter {whenChanged - le $b} -Server “vsat.kunder.com” …
  • CategoryInfo : InvalidArgument: (:slight_smile: [Get-ADUser], ParameterBindingException
  • FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.ActiveDirectory.Management.Commands.GetADUser

 

Thanks for sharing the error, you can see its complaining about ‘-’. There is a space between hyphen and filter. It should be -Filter.

Thank, you. It is working fine now. Thanks