I have return a powershell script to get AD user properties and his list of group memberships and exporting the results to csv file. I am reading a list of users from text file. Below is the script
$users = ForEach ($user in $(Get-Content C:\temp\MA_usersB.txt)) {
Get-ADPrincipalGroupMembership $user | select name, groupcategory | Get-ADUser -Filter "samaccountname -eq '$user'" -Properties SurName, GivenName, SamAccountName, Manager |
Select SurName, GivenName,SamAccountName, Enabled, @{label="Manager";expression={(Get-ADUser $_.Manager -Properties DisplayName).DisplayName}}
}
$users |
Select-Object SurName, GivenName, SamAccountName, Enabled, Manager, name groupcategory |
Export-CSV -Path C:\uday\MA\listusers.csv -notype
but i am getting Piping error any help in fixing the issue much appreciated.
PS C:\>
PS C:\> .\listuser.ps1
Get-ADUser : The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and its properties do not match any of the parameters that take pipeline input.
At C:\temp\listuser.ps1:4 char:69
- Get-ADPrincipalGroupMembership $user | select name, groupcategory | Get-ADUser - ...
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- CategoryInfo : InvalidArgument: (@{name=Domain U...egory=Security}:PSObject) [Get-ADUser], ParameterBindingException
- FullyQualifiedErrorId : InputObjectNotBound,Microsoft.ActiveDirectory.Management.Commands.GetADUser
Get-ADUser : The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and its properties do not match any of the parameters that take pipeline input.
At C:\uday\listuser.ps1:4 char:69
- Get-ADPrincipalGroupMembership $user | select name, groupcategory | Get-ADUser - ...
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- CategoryInfo : InvalidArgument: (@{name=Dir-PMO_...egory=Security}:PSObject) [Get-ADUser], ParameterBindingException
- FullyQualifiedErrorId : InputObjectNotBound,Microsoft.ActiveDirectory.Management.Commands.GetADUser
Get-ADUser : The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and its properties do not match any of the parameters that take pipeline input.
At C:\uday\listuser.ps1:4 char:69
- Get-ADPrincipalGroupMembership $user | select name, groupcategory | Get-ADUser - ...
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- CategoryInfo : InvalidArgument: (@{name=Dir-PM_M...egory=Security}:PSObject) [Get-ADUser], ParameterBindingException
- FullyQualifiedErrorId : InputObjectNotBound,Microsoft.ActiveDirectory.Management.Commands.GetADUser