ASP.NET Weblogs

Welcome to ASP.NET Weblogs Sign in | Join | Help
in Search

The Technical Adventures of Adam Weigert

PowerShell: Convert Active Directory IADSLargeInteger to System.Int64

This PowerShell function will convert an IADSLargeInteger ComObject to a long/Int64 value. Extremely helpful when trying to work with Active Directory attributes like "pwdLastSet" or "lastLogonTimestamp".

function ConvertADSLargeInteger([object] $adsLargeInteger)
{
    $highPart = $adsLargeInteger.GetType().InvokeMember("HighPart", [System.Reflection.BindingFlags]::GetProperty, $null, $adsLargeInteger, $null)
    $lowPart  = $adsLargeInteger.GetType().InvokeMember("LowPart",  [System.Reflection.BindingFlags]::GetProperty, $null, $adsLargeInteger, $null)

    $bytes = [System.BitConverter]::GetBytes($highPart)     $tmp   = [System.Byte[]]@(0,0,0,0,0,0,0,0)     [System.Array]::Copy($bytes, 0, $tmp, 4, 4)     $highPart = [System.BitConverter]::ToInt64($tmp, 0)

    $bytes = [System.BitConverter]::GetBytes($lowPart)     $lowPart = [System.BitConverter]::ToUInt32($bytes, 0)       return $lowPart + $highPart }

Comments

 

BS on PoSH - Blog » Dealing iADSLargeInteger in Powershell said:

Pingback from  BS on PoSH - Blog  » Dealing iADSLargeInteger in Powershell

August 13, 2007 2:29 PM
 

PowerShell: Convert Active Directory IADSLargeInteger to System.Int64 said:

Pingback from  PowerShell: Convert Active Directory IADSLargeInteger to System.Int64

November 26, 2007 3:24 PM
 

Developer Support ADSI, WMI, Powershell Team Blog said:

Password Settings objects were introduced in Windows 2008 AD to allow administrators more control over

March 4, 2009 1:02 PM
 

Powershell: How do I query pwdLastSet and have it make sense? Drija said:

Pingback from  Powershell: How do I query pwdLastSet and have it make sense? Drija

April 24, 2011 4:13 PM