Link to home
Start Free TrialLog in
Avatar of ptea
ptea

asked on

QAD-Cmdlets LastLogonTimestamp

Hi there,

I want to run this query using the Qest AD Powershell extensions:

get-qaduser -Enabled -includeallproperties -Sizelimit 0 | select -property name,samaccountname,lastlogontimestamp

The query works but after some hundret accounts it failed with the following error message:
Get-QADUser : '040930075424Z' is not generalized time UTC string.
At line:1 char:12
+ get-qaduser <<<<  -Enabled -includeallproperties -Sizelimit 0 | select -property name,samaccountname,lastlogontimesta
mp
    + CategoryInfo          : NotSpecified: (:) [Get-QADUser], FormatException
    + FullyQualifiedErrorId : System.FormatException,Quest.ActiveRoles.ArsPowerShellSnapIn.Powershell.Cmdlets.GetUserCmdlet


Anyboday knows how to get rid of this? thx
Avatar of Chris Dent
Chris Dent
Flag of United Kingdom of Great Britain and Northern Ireland image


Neat...

It could be a bug. Lets see if we can dig a bit deeper. First we need to know who throws the error if we can. Debugging version attached.

Chris
$VerbosePreference = "continue"
Get-QADUser -Enabled -IncludeAllProperties -Sizelimit 0 | 
  ForEach-Object {
    # Attempt to get the timestamp, should throw an error
    $TimeStamp = $_.LastLogonTimeStamp
    # If it did. Write debugging information
    If (!$?) {
      $User = ([ADSISearcher]"(distinguishedName=$($_.DN))").FindOne()
      Write-Verbose "Name: $($_.Name)"
      Write-Verbose "TimeStamp (raw): $($User.Properties['lastlogontimestamp'][0])"
    }
 
    $_ | Select Name, Samaccountname, LastLogonTimeStamp
}

Open in new window

Avatar of ptea
ptea

ASKER

Thx Chris - but the debugging is not working... get the same message as before, no additional information...

cheers

Hmm okay, this one?

I'm hoping it won't error until it gets to:

$_ | Select Name, SamAccountName, LastLogonTimeStamp

If it dies before that it's going to be a little more difficult.

Chris
$VerbosePreference = "continue"
Get-QADUser -Enabled -IncludeAllProperties -Sizelimit 0 | 
  ForEach-Object {
    $User = ([ADSISearcher]"(distinguishedName=$($_.DN))").FindOne()
    Write-Verbose "Name: $($_.Name)"
    Write-Verbose "TimeStamp (raw): $($User.Properties['lastlogontimestamp'][0])"
 
    $_ | Select Name, Samaccountname, LastLogonTimeStamp
}

Open in new window

Avatar of ptea

ASKER

...in principle nice stuff - get the debug information of each user account, but crashes at the same position without showing debug-info...

I run the query without LogonTimeStamp to get the object which is causing the troubles. Verified the values and for me everything is fine... (checked it with the Sysinternals AD Explorer)...

But when I run the query against this user account only I get the same error... hmm strange stuff - I hope this is the only account doing bad things, is it possible to exclude it?

You could feed it an LDAP filter to prevent it finding the account. e.g.

-LdapFilter "(!(name=TheBadAccount))"

It'd be nice to know why it's getting upset about the value though.

Chris
Avatar of ptea

ASKER

thx for the input... nice to be able to use normal LdapFilters - i did not know.... strange whats going on with this account.... Yeah would be nice to figgure it out - but I can't find the bug...

really bad - I used the filter with the samaccountname -> same result. I disabled the account temporary, as I am using the switch "-Enabled" only active account should be checked -> same result... So we have the problem not only with this account - I identified the 2nd account and excluded it too.

Do you know is there an option like "SilentlyContinue" available for WMI?

The really bad thing is, that the query stops...

Thx for the good support...




There is, but it may not do any good if it's throwing a terminating error.

For those accounts, can you run:

([ADSISearcher]"(&(name=The Name)(objectClass=user)(objectCategory=person))").FindAll() |
  Select-Object `
    @{n='Name';e={ $_.Properties["name"][0] }},
    @{n='lastLogonTimeStamp';e={ $_.Properties["lastlogontimestamp"][0] }}

It should give you a numeric value for lastLogonTimeStamp. Does it?

If so, please run:

[DateTime]::FromFileTime(TheNumericValue)

See if that gives you a sane date?

Chris
ASKER CERTIFIED SOLUTION
Avatar of ptea
ptea

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This question has been classified as abandoned and is being closed as part of the Cleanup Program.  See my comment at the end of the question for more details.