locked
Unable to use -properties * in PowerShell Version 5 RRS feed

  • Question

  • Afternoon,

    I have been using -properties * for years when needing to find out the full info on a cmdlet but since my windows 10 machine updated the powershell to version 5 this command no longer works, i have tested my script on a PC still running version 4 and it works fine. any ideas how i can get this working or if there is a workaround? If i specify the property then the script will run but this feature is really handy when running a new cmdlet and seeing what info it has to offer


    the script i am running is:

    get-aduser -identity t.mooney -properties *

    error:

    get-aduser : Object reference not set to an instance of an object.
    At line:8 char:1
    + get-aduser -identity t.mooney -properties *
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (t.mooney:ADUser) [Get-ADUser], NullReferenceException
        + FullyQualifiedErrorId : ActiveDirectoryCmdlet:System.NullReferenceException,Microsoft.ActiveDirectory.Management.Commands.GetADUser

    Monday, January 22, 2018 1:38 PM

All replies

  • Hello,

    The error message: "Object reference not set to an instance of an object." indicates, that the object "t.mooney" could not be found.

    Does the user: "t.mooney" exists in your environment?

    Maybe try to put the name in quotes like (should not be an issue):

    get-aduser -identity "t.mooney" -properties *

    Monday, January 22, 2018 1:42 PM
  • User doesn't exist or you have entered a wrong user name.

    Double check the user name


    Please click on Propose As Answer or to mark this post as and helpful for other people. This posting is provided AS-IS with no warranties, and confers no rights.

    Monday, January 22, 2018 1:44 PM
  • hi thank you but that still didnt work, the user exists as i am that user. if i specify the property as per below then it works fine, this script used to work up until powershell 5 was installed and i cant seem to uninstall it back down to version 4.

    if i run the below i get the following results:

    get-aduser -identity "t.mooney" -properties lastlogon

    DistinguishedName : 
    Enabled           : True
    GivenName         : Tom
    lastlogon         : 131610881366774376
    Name              : Tom Mooney
    ObjectClass       : user
    ObjectGUID        : 06b341a1-7f07-42cb-922b-f9ad643bf99d
    SamAccountName    : t.mooney
    SID               : S-1-5-21-1806706506-2363530942-2143674110-13293
    Surname           : Mooney

    Monday, January 22, 2018 1:54 PM
  • You need to update the RSAT module to the one specifically for Windows 10.


    \_(ツ)_/

    Monday, January 22, 2018 1:58 PM
  • I use -Properties * on my Windows 10 computer with PS version 5 with no problems.


    Richard Mueller - MVP Enterprise Mobility (Identity and Access)

    Monday, January 22, 2018 2:50 PM
  • figured it out, it is a permissions issue with contacting the Active Directory, added myself into the correct security group resolved it, bizarre that the permission allows me to specify the property but not display all.

    thank you all for your help

    Monday, January 22, 2018 3:29 PM
  • I should note, when you use -Properties * with the AD module cmdlets, it does not reveal all properties supported by the cmdlet. All default properties are retrieved, even those with no values. But only the extended properties that have values (for the first object retrieved, if more than one satisfies a filter) will be retrieved.

    For example, Surname is a default property exposed by Get-ADUser, so the cmdlet will turn this property for all user objects retrieved, even if some of the users have no value assigned. But DisplayName is an extended property. If the first user (or the only user) retrieved has no value assigned, then this property is not included in the results, even if subsequent users in the array of results have a value assigned. This is explained in the Wiki:

    https://social.technet.microsoft.com/wiki/contents/articles/12031.active-directory-powershell-ad-module-properties.aspx

    The default and extended properties exposed by Get-ADUser are documented here:

    https://social.technet.microsoft.com/wiki/contents/articles/12037.active-directory-get-aduser-default-and-extended-properties.aspx


    Richard Mueller - MVP Enterprise Mobility (Identity and Access)

    Monday, January 22, 2018 4:03 PM