I am trying to get the inactive users from AD with the following code:
# set the date (the number of days)
$NumberOfDays = 60
# set the timeframe ranging for the amount of days entered
$TimeRange = (Get-Date).Adddays(-($NumberOfDay))
# checks for inactive users within 60 days timeframe
Get-ADUser -Filter {LastLogonTimeStamp -lt $TimeRange } -Properties *
and I would like to add this additional filter:
Get-ADUser -Filter {Name -like "f_*"} -Properties * | Format-Table Name,SamAccountName
Can anyone help me how to merge these 2, I am a newbie and struggling :) .....
CodePudding user response:
"See this link for info on using the -and/-or operator. Something like Get-ADUser -Filter {(Name -like "f_*") -and (LastLogonTimeStamp -lt $TimeRange )} – "
Vivek Kumar Singh from the comments