Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8261647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T03:28:54+00:00 2026-06-08T03:28:54+00:00

My goal is to create a single object in powershell that shows the AD

  • 0

My goal is to create a single object in powershell that shows the AD display name and password expiration date for all non-disabled users.
This is relatively easy. However, the date is retrieved in an unreadable format so I convert the date.

Creating the two variables that contain the data I want is working.
The problem is when I try to combine those two variables I get a single object with two headers as expected but the two columns below are empty.

I’m using PowerShell V2 on Win 7 Pro SP1

Any ideas what the issue could be?

# Get users DisplayName and password expiration time from AD
$msdsComputed = Get-ADUser -filter {Enabled -eq $True -and PasswordNeverExpires -eq  $False} -Properties "DisplayName", "msDS-UserPasswordExpiryTimeComputed" |  
        Where-Object {$_.DisplayName -ne $null} 

# Convert date to human readable format
$ExpiryDate = $msdsComputed | Foreach-Object {
             ([datetime]::FromFileTime(($_)."msDS-UserPasswordExpiryTimeComputed")) 
                          } | Select-Object "DateTime"



$combined = @{            
              DisplayName   = $msdsComputed.DisplayName
              ExpiryDate    = $ExpiryDate.DateTime
             }
New-Object PSObject -Property $combined | ConvertTo-Csv -NoTypeInformation
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T03:28:57+00:00Added an answer on June 8, 2026 at 3:28 am

    Here’s a revised version of your script without looping issues:

    $reportObject = @()
    $userList = Get-ADUser -filter {Enabled -eq $True -and PasswordNeverExpires -eq  $False} -Properties "DisplayName", "msDS-UserPasswordExpiryTimeComputed" |  Where-Object {$_.DisplayName -ne $null}
    $userList | %{
    
        $output = "" | Select DisplayName, ExpiryDate
        $output.DisplayName = $_.DisplayName
        $output.ExpiryDate = ([datetime]::FromFileTime($_."msDS-UserPasswordExpiryTimeComputed")).DateTime
        $reportObject += $output
        #Next 2 Lines provide debugging... I'm not sure the date time portion will work without having AD to play with
        $output | fl *
        ([datetime]::FromFileTime($_."msDS-UserPasswordExpiryTimeComputed")).DateTime 
    }
    
    $reportObject | Convertto-CSV -NoTypeInformation
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

High Level Goal: Create a single Maven Web Application project that can be used
I've created an object Chartblock that implements QGraphicsItem. My goal is to create a
My goal is to create an entry form (addnew.php) that will allow me to
My goal is to create a Web Service client that runs in a standalone
My goal is to create a reusable Attached Behavior for a FlowDocumentScrollViewer, so that
My goal is to create a log app, apart from my main app, that
Goal: to create a percentage column based off the values of calculated columns. Here's
Duplicate: PHP validation/regex for URL My goal is create a PHP regex for website
I am very new to Json and my goal to create the Json output
My goal is to create a canned email on my server and then send

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.