Discussion:
How to Get LastLogoff detail in AD through Powershell
(too old to reply)
m***@gmail.com
2006-09-29 00:32:01 UTC
Permalink
I'm Unable to See Some attributes like

badPasswordTime : {System.__ComObject}
lastLogoff : {System.__ComObject}
lastLogon : {System.__ComObject}

............etc when i say $a = [ADSI]("LDAP://CN = User, OU= My List,
DC = sample, DC = com")

Is there any possible way to retrieve this info? Is there any PSBASE
method inplace to retrive these? I'm pretty new to scripting and i
appreciate the way powershell allows to administer things!!
Can SomeOne here help me?
/\/\o\/\/ [MVP]
2006-09-29 08:56:02 UTC
Permalink
# Setting User must change password at next Logon

$user.pwdLastSet = -1

# Reading password last set value

$ds = New-Object directoryservices.directorysearcher($user)

MowPS>[datetime]::fromfiletime(($ds.findone().properties.pwdlastset)[0])

Monday, July 17, 2006 5:07:05 PM

# Un-setting user must chage password at next logon
$user.pwdLastSet = 0

MowPS>$user.InvokeGet('PasswordLastChanged')

***************************

MowPS>[datetime]::fromfiletime(($ds.findone().properties.pwdlastset)[0])

More info :
http://mow001.blogspot.com/2006/08/powershell-and-active-directory-part-8.html
http://mow001.blogspot.com/2006/01/msh-snap-in-to-translate.html
http://mow001.blogspot.com/2006/01/get-users-lastlogontime-and.html

Greetings /\/\o\/\/
Post by m***@gmail.com
I'm Unable to See Some attributes like
badPasswordTime : {System.__ComObject}
lastLogoff : {System.__ComObject}
lastLogon : {System.__ComObject}
.............etc when i say $a = [ADSI]("LDAP://CN = User, OU= My List,
DC = sample, DC = com")
Is there any possible way to retrieve this info? Is there any PSBASE
method inplace to retrive these? I'm pretty new to scripting and i
appreciate the way powershell allows to administer things!!
Can SomeOne here help me?
m***@gmail.com
2006-09-29 16:29:22 UTC
Permalink
Thanks, MOW

Working Great!! But i see that when i retrive the lastlogoff of a User
it gives me inappropriate(Unbelievable) Time, Look at the following

~!~!~ 09/29/2006 21:52:48 ~!~!~ [ C:\Documents and Settings\ ]
[datetime]::fromfiletime(($ds.findone().properties.lastlogon)[0])
Friday, September 29, 2006 9:39:06 PM



~!~!~ 09/29/2006 21:53:20 ~!~!~ [ C:\Documents and Settings\ ]
[datetime]::fromfiletime(($ds.findone().properties.lastlogoff)[0])
Monday, January 01, 1601 5:30:00 AM

Does anyone know why the lastlogoff is inaccurate and the way to get
the right logoff time??
# Setting User must change password at next Logon
$user.pwdLastSet = -1
# Reading password last set value
$ds = New-Object directoryservices.directorysearcher($user)
MowPS>[datetime]::fromfiletime(($ds.findone().properties.pwdlastset)[0])
Monday, July 17, 2006 5:07:05 PM
# Un-setting user must chage password at next logon
$user.pwdLastSet = 0
MowPS>$user.InvokeGet('PasswordLastChanged')
***************************
MowPS>[datetime]::fromfiletime(($ds.findone().properties.pwdlastset)[0])
http://mow001.blogspot.com/2006/08/powershell-and-active-directory-part-8.html
http://mow001.blogspot.com/2006/01/msh-snap-in-to-translate.html
http://mow001.blogspot.com/2006/01/get-users-lastlogontime-and.html
Greetings /\/\o\/\/
Post by m***@gmail.com
I'm Unable to See Some attributes like
badPasswordTime : {System.__ComObject}
lastLogoff : {System.__ComObject}
lastLogon : {System.__ComObject}
.............etc when i say $a = [ADSI]("LDAP://CN = User, OU= My List,
DC = sample, DC = com")
Is there any possible way to retrieve this info? Is there any PSBASE
method inplace to retrive these? I'm pretty new to scripting and i
appreciate the way powershell allows to administer things!!
Can SomeOne here help me?
Lee Flight
2006-09-29 16:51:46 UTC
Permalink
Hi

the time conversion is working correctly it's just that
unfortunately lastLogoff is not used in AD and there is
no other attribute that stores the logoff time. If you
do a Google Groups search for lastLogoff you will see that this a
common problem and see some the suggested solutions.

Lee Flight
Post by m***@gmail.com
Thanks, MOW
Working Great!! But i see that when i retrive the lastlogoff of a User
it gives me inappropriate(Unbelievable) Time, Look at the following
~!~!~ 09/29/2006 21:52:48 ~!~!~ [ C:\Documents and Settings\ ]
[datetime]::fromfiletime(($ds.findone().properties.lastlogon)[0])
Friday, September 29, 2006 9:39:06 PM
~!~!~ 09/29/2006 21:53:20 ~!~!~ [ C:\Documents and Settings\ ]
[datetime]::fromfiletime(($ds.findone().properties.lastlogoff)[0])
Monday, January 01, 1601 5:30:00 AM
Does anyone know why the lastlogoff is inaccurate and the way to get
the right logoff time??
# Setting User must change password at next Logon
$user.pwdLastSet = -1
# Reading password last set value
$ds = New-Object directoryservices.directorysearcher($user)
MowPS>[datetime]::fromfiletime(($ds.findone().properties.pwdlastset)[0])
Monday, July 17, 2006 5:07:05 PM
# Un-setting user must chage password at next logon
$user.pwdLastSet = 0
MowPS>$user.InvokeGet('PasswordLastChanged')
***************************
MowPS>[datetime]::fromfiletime(($ds.findone().properties.pwdlastset)[0])
http://mow001.blogspot.com/2006/08/powershell-and-active-directory-part-8.html
http://mow001.blogspot.com/2006/01/msh-snap-in-to-translate.html
http://mow001.blogspot.com/2006/01/get-users-lastlogontime-and.html
Greetings /\/\o\/\/
Post by m***@gmail.com
I'm Unable to See Some attributes like
badPasswordTime : {System.__ComObject}
lastLogoff : {System.__ComObject}
lastLogon : {System.__ComObject}
.............etc when i say $a = [ADSI]("LDAP://CN = User, OU= My List,
DC = sample, DC = com")
Is there any possible way to retrieve this info? Is there any PSBASE
method inplace to retrive these? I'm pretty new to scripting and i
appreciate the way powershell allows to administer things!!
Can SomeOne here help me?
Loading...