Convert Int64 TimeStamp To DateTime In Powershell
Maybe your like
In Powershell, we can use the .Net function FromFileTime and convert the output to DateTime format.
$timestamp = "131099683087123361" [DateTime]::FromFileTimeutc($timestamp)You can also convert the standard datetime to timestamp value by using the function ToFileTimeUtc.
$date = Get-Date $date.ToFileTimeUtc()In Active Directory environment, the attributes LastLogonTimeStamp and PwdLastSet are stored as Int64 TimeStamp. When you query these properties by using Get-ADUser cmdlet, you need to explicitly convert LastLogonTimeStamp value into datetime value.
Get-ADUser -Identity 'Smith' -Properties LastLogonTimeStamp | Select-Object -Property "Name", @{n="LastLogon";e={[datetime]::FromFileTime($_."LastLogonTimeStamp")}}The following powershell command convert AD user’s PwdLastSet value to datetime value.
Get-ADUser -Identity 'Smith' -Properties PwdLastSet | Select-Object -Property "Name", @{n="PwdLastSet";e={[datetime]::FromFileTime($_."PwdLastSet")}}Share this:
- X
Related Posts
- PowerShell - Convert Large Integer value to DateTime string
- Powershell : Convert SecureString to Plain Text
- PowerShell - Convert Ticks to DateTime and Vise Versa
- Convert SID to Username using Powershell
- Convert CSV string to PS Object in PowerShell
1 thought on “Convert Int64 TimeStamp to DateTime in Powershell”
-
It works fine, thanks a lot for the trick 🙂
Reply
Leave a Comment Cancel reply
Comment
Name Email WebsiteSave my name, email, and website in this browser for the next time I comment.
Categories
- Powershell
- Microsoft 365
- Azure AD
- SharePoint Online
- Exchange Online
- Microsoft Teams
- Office 365 Groups
- Active Directory
- Microsoft Graph
- PnP-PowerShell
- CSOM
Recent Posts
- Get Azure AD (Entra ID) App-Only Access Token with PowerShell
- Working with REST API in PowerShell using Invoke-RestMethod
- M365 User SignIn Activity – Neither tenant is B2C or tenant doesn’t have premium license
- How to Join or Concatenate String and Number Using PowerShell
- Find Location and County by IP Address with PowerShell
- Microsoft 365
- Azure AD
- SharePoint Online
- Exchange Online
- Microsoft Teams
- Microsoft 365 Groups
- OneDrive for Business
- Azure AD Authentication
- Active Directory
- Exchange Server
- PowerShell
- PnP PowerShell
- Microsoft Graph
- CSOM
- VBScript
Follow us
Tag » Active Directory Pwdlastset Convert To Date Powershell
-
Get-AdUser PwdLastSet - Get Aduser Last Password Change
-
Efficiently Converting Pwdlastset To Datetime In A Single Line.
-
Converting Pwdlastset To Datetime Datatype Not Working From Hash ...
-
Powershell Output Of Ad-user PwdLastSet And LastLoginTimeStamp
-
PowerShell Code: Convert Integer8 To Date - Active Directory Security
-
TIP: Active Directory Module Date Properties - Tech Wizard
-
Powershell: How Do I Query PwdLastSet And Have It Make Sense?
-
LDAP, Active Directory & Filetime Timestamp Converter
-
Active Directory Powershell: Quick Tip LastLogonTimeStamp And ...
-
Powershell Script - Users Pwdlastset - Spiceworks Community
-
Finding Users Who Have Not Changed Their Password Recently
-
How To Find Last Password Change Date With Or Without PowerShell
-
How To Convert Active Directory TimeStamp Property To DateTime
-
Integer8 Attributes