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?
Format-Table, which is the required cmdlet to answer this question!Format-Tablecmdlet. If someone didn't know that theFormat-Tablecmdlet existed, reading your answer would not resolve their problem, it would only tell them why they were having a problem. That's an explanation, not an answer. It'd be like going to the doctor saying, "My arm hurts," and your doctor spent 20 minutes explaining to you how the body experiences pain.