Reputation: 23
How do i get the Description property in Get-ADComputer's default set? I need to make this persistent across sessions (by writing it to $profile would be great).
What i get:
# get-adcomputer PC
DistinguishedName : CN=PC,OU=Computers,DC=myDC,DC=local
DNSHostName : PC.local
Enabled : True
Name : PC
ObjectClass : computer
ObjectGUID : xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx
SamAccountName : PC$
SID : S-x-x-xx-xxxxxx-xxxxxxx-xxxxxxx-xxxxx
UserPrincipalName :
# get-adcomputer PC -Property Description
Description : Some box out there, lost in the corporate shenanigans
DistinguishedName : CN=PC,OU=Computers,DC=myDC,DC=local
DNSHostName : PC.local
Enabled : True
Name : PC
ObjectClass : computer
ObjectGUID : xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx
SamAccountName : PC$
SID : S-x-x-xx-xxxxxx-xxxxxxx-xxxxxxx-xxxxx
UserPrincipalName :
What i want:
# get-adcomputer PC
Description : Some box out there, lost in the corporate shenanigans
DistinguishedName : CN=PC,OU=Computers,DC=myDC,DC=local
DNSHostName : PC.local
Enabled : True
Name : PC
ObjectClass : computer
ObjectGUID : xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx
SamAccountName : PC$
SID : S-x-x-xx-xxxxxx-xxxxxxx-xxxxxxx-xxxxx
UserPrincipalName :
I'm using Powershell 4.0 on Windows 8.1.
Upvotes: 2
Views: 3997
Reputation: 68263
One option is to use $PSDefaultParameterValues
Add this to your profile:
$PSDefaultParameterValues['Get-ADComputer:Properties'] = 'Description'
Note that this doesn't actually change the default values, it will just cause 'Description' to be the default value of the -Properties parameter.
If you override that by specifying -Properties and don't include Description, it won't be there.
Upvotes: 1
Reputation: 43489
According to the documentation available here, Description is part of the extended properties. To quote the relevant paragraph:
Many Active Directory Get-AD* cmdlets also support extended properties. These are only retrieved if they are specified in the -Properties parameter of the cmdlet. Many extended properties can also be assigned values using the corresponding Set-AD* cmdlet. Again, the names of these properties may or may not match the LDAPDisplayName of the corresponding Active Directory attribute.
So, I think the only way to get what you want is to define your own alias.
Upvotes: 0