I want to sort A-Z based on Name attribute. After I want to convert HTML table via | ConvertTo-Html -Fragment -As Table
for object variable. How can I do that ?
thanks,
Script :
$cutoff = (get-date).AddDays(-200)
$Objects = Get-ADUser -Filter {LastLogonDate -lt $cutoff -and Enabled -eq $True} -SearchBase 'DC=contoso,DC=com' -SearchScope Subtree -Properties 'SamAccountName' , 'Name'
foreach ($_ in $Objects) {
$LogonDate = (Get-RealLogonDate -sAMAccountName $_.SamAccountName -Domain contoso.com).DateTime
$Object = [ordered] @{
DisplayName = $_.Name
LastLogon = $LogonDate
}
[PSCUstomObject] $Object
}