Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Format-Table not displaying a columns data

$
0
0

I am using the powershell command below to read a csv file and match the computer name to the employee name where the last login date is 181 days old. For some reason the Employee_Name column in the output is only displaying {} on each row. Any idea why its not returning the employee name?

    Import-Module ActiveDirectory
    $Days = (Get-Date).AddDays(-181) 


    $Computers = @{}
    Import-CSV -Path c:\PS\ComputerNames.CSV | % { $Computers[$_.Computer_Name] = $_.Employee_Name }
    Get-ADComputer -Property Name,lastLogonDate -Filter  {lastLogonDate -lt $Days} -Server servername -Searchbase "OU=US,DC=Domain,DC=net" | ? { $Computers.Keys -contains $_.Computer_Name } | select Name,lastLogonDate,@{n='Employee_Name';e={$Computers[$_.Computer_Name]}} | ft


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>