IM BACK! Ok, here is the issue.
I am trying to create a script that exports a list of users. The issue I am running into is the client wants to be able to get it by an inputted value.
So far so good, it exports the list. Now here is the rub. When a date is inputted the export just gets everything instead of the users created before the date provided.
#Looking for the date of export $date = Read-Host 'How many days ago would you like the export to be run?(Press enter if it is a current export)' #Taking the input from the date variable and subtracting it from the current date $week = (Get-Date).AddDays(-$date) #Getting export. No input means anyone created is exported. Otherwise it exports before the given date in $week if ($date -eq '') { Get-ADUser -Filter 'enabled -eq $true' -properties Department, Description, title, enabled -SearchBase "insert company ou"|export-csv users.csv } else { Get-ADUser -Filter 'enabled -eq $true' -properties Department, Description, title, enabled -SearchBase "*insert company ou"|where { $_.whencreated -le $week } |export-csv users.csv Write-Host $week }