The property you want isn't available in the object returned by WMI (but you knew that). So, what you want needs help from the Get-LocalUser cmdlet.
Here's a rearranged (and slightly enhanced) version of the code I posted earlier.
$server_list = Get-ADComputer -Filter * |
Select-Object Name,OperatingSystem,OperatingSystemVersion,ipv4Address
$server_list |
Export-CSV ADcomputerslist.csv -NoTypeInformation -Encoding UTF8
Invoke-Command -ComputerName $server_list -ScriptBlock { # NOTE: if the local machine is in $server_list it will generate an error.
$props = @{
PSComputername = ""
Name = ""
Status = ""
Disabled = ""
AccountType = ""
Lockout = ""
PasswordRequired = ""
PasswordChangeable = ""
PasswordLastSet = ""
}
Get-WmiObject -Class Win32_UserAccount -Filter "LocalAccount = $true" -ErrorAction Continue 2>&1 |
ForEach-Object{
if ($_.pstypenames -contains "System.Management.Automation.ErrorRecord"){
# skip any errors
# if you want to report errors, the entire ErrorRecord is available in $_
}
else {
$props.PSComputername = $_.PSComputername
$props.Name = $_.name
$props.Status = $_.Status
$props.Disabled = $_.Disabled
$props.AccountType = $_.AccountType
$props.Lockout = $_.Lockout
$props.PasswordRequired = $_.PasswordRequired
$props.PasswordChangeable = $_.PasswordChangeable
$props.PasswordLastSet = (Get-LocalUser $_.Name).PasswordLastSet
}
[PSCustomObject]$props
}
} | Export-Csv LocalAccount.csv -NoTypeInformation