So, I got this script :
$userName = Read-Host -Prompt 'Input User ID'
echo "[$userName]"
$Properties =
@(
'DisplayName',
'SamAccountName',
'Enabled',
'Created',
'EmailAddress',
'title',
'manager',
'AccountLockoutTime',
'Department',
'Description',
'Division',
'LastLogonDate',
'LockedOut',
'PasswordLastSet'
)
Get-ADUser $userName -Properties $Properties | select $Properties
Get-ADPrincipalGroupMembership $userName | select name
When I execute only the last command:
Get-ADPrincipalGroupMembership $userName | select name
The output is :
name
----
Domain Users
blabla
blabla Users
IT.BG
blabla users
But when I run the script the output is changed to :
name : Domain Users
name : blabla
name : blabla Users
name : blabla
name : blabla
name : blabla users
Can someone tell me why this is happening and how can I fix it?