How to read a property `ms-Mcs-AdmPwdExpirationTime` from ActiveDirectory
11,766
This works for me in powershell:
$comp = Get-ADComputer Laptop8 -Properties ms-MCS-AdmPwdExpirationTime
$([datetime]::FromFileTime([convert]::ToInt64($comp.'ms-MCS-AdmPwdExpirationTime',10)))
good luck Sem
Related videos on Youtube
Author by
StepUp
Updated on September 18, 2022Comments
-
StepUp over 1 year
I am trying to read Expiration time of administrator password from
ActiveDirectory
:Dim DC = New PrincipalContext(ContextType.Domain) Dim cmp = ComputerPrincipal.FindByIdentity(DC, hostnm) Dim desting As String = cmp.DistinguishedName Dim de As New DirectoryEntry("LDAP://" & desting) pwdexp = de.Properties("ms-Mcs-AdmPwdExpirationTime").Value.ToString()
But what I see is just
<COM Type>
:However, expiration time of administrator password can be easily read by PowerShell:
$TestValue = [adsi]"LDAP://CN=xxx,OU=xxx,OU=xxx,OU=xxx,OU=xxx,DC=xxx,DC=xxx,DC=xx" $TestValue.ConvertLargeIntegerToInt64($Testvalue."ms-Mcs-AdmPwdExpirationTime"[0])
And I know that there is a such property:
Interestingly, but I can read another parameter
ms-Mcs-AdmPwd
:Dim DC = New PrincipalContext(ContextType.Domain) Dim cmp = ComputerPrincipal.FindByIdentity(DC, hostnm) Dim desting As String = cmp.DistinguishedName Dim de As New DirectoryEntry("LDAP://" & desting) pwdexp = de.Properties("ms-Mcs-AdmPwdExpirationTime").Value.ToString()
and value can be seen from debugger:
How to read a property
ms-Mcs-AdmPwdExpirationTime
correctly?-
Vomit IT - Chunky Mess Style over 6 yearsFYI... You might look over the simple command
net user /domain administrator
just like that and then see the value for the field Password Expires.
-
-
Michał Sacharewicz about 5 yearsPlease note that the question was about VB solution. PowerShell solution was already known in original question.