SAM2009
asked on
Need help to understand Powershell code.
Hi,
Is someone can tell me what is the difference between "Get-ADUser User -Properties UserPrincipalName | select SamAccountName,UserPrincip alName" and ""Get-ADUser User | select SamAccountName,UserPrincip alName" because I got same result when I export it to csv:
1)
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----
$SamAccount = Import-Csv "C:\SamAccountName.csv"
$SamAccount | % {Get-ADUser $_.SamAccountName -Properties UserPrincipalName | select SamAccountName,UserPrincip alName
} | Export-csv "C:\UserPrincialName.csv" -NoTypeInformation
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----
2)
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----
$SamAccount = Import-Csv "C:\SamAccountName.csv"
$SamAccount | % {Get-ADUser $_.SamAccountName | select SamAccountName,UserPrincip alName
} | Export-csv "C:\UserPrincialName.csv" -NoTypeInformation
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----
Is someone can tell me what is the difference between "Get-ADUser User -Properties UserPrincipalName | select SamAccountName,UserPrincip
1)
--------------------------
$SamAccount = Import-Csv "C:\SamAccountName.csv"
$SamAccount | % {Get-ADUser $_.SamAccountName -Properties UserPrincipalName | select SamAccountName,UserPrincip
} | Export-csv "C:\UserPrincialName.csv" -NoTypeInformation
--------------------------
2)
--------------------------
$SamAccount = Import-Csv "C:\SamAccountName.csv"
$SamAccount | % {Get-ADUser $_.SamAccountName | select SamAccountName,UserPrincip
} | Export-csv "C:\UserPrincialName.csv" -NoTypeInformation
--------------------------
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ok but what the difference between -properties and -property?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks all for your help!
DistinguishedName
Enabled
GivenName
Name
ObjectClass
ObjectGUID
SamAccountName
SID
Surname
UserPrincipalName