<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-M74D8PB" height="0" width="0" style="display:none;visibility:hidden">
Loading
Skip to NavigationSkip to Main Content
0D50Z00008G7Um6SAFOkta Classic EngineIntegrationsAnswered2024-04-30T09:18:25.000Z2018-03-28T18:38:08.000Z2018-08-12T04:15:09.000Z
Powershell script to list for users that were deprovisioned over 60 days from current date
I currently have the below script that shows me all the users in a deprovisioned status but I would like to filter that further only those with a statusChanged date older than 60 days.

I am not a developer and am very new to scripting in powershell so any help you can provide is appreciated.

 

Sample Script below

------------------------------------------------------------------------------------------

$users = oktaListDeprovisionedUsers -oOrg PROD1

$toexport = New-Object System.Collections.ArrayList

 

New-Item -Path "c:\" -Name "OktaExport" -Itemtype directory -Force

 

Foreach ($u in $users)

{

    $line = @{

              status = $u.status

              employeeid = $u.profile.employeeNumber

              firstName = $u.profile.firstName

              lastName = $u.profile.lastName

              email = $u.profile.email

              department = $u.profile.department

              supervisor = $u.profile.manager

              created = $u.created

              lastUpdated = $u.lastUpdated

              login = $u.profile.login

              title = $u.profile.title

              GroupName = $u.profile.Group_Name

              Organization = $u.profile.organization

              Location = $u.profile.workday_location

              User_type = $u.profile.userType

              StatusChanged = $u.StatusChanged

                                   

 

             }

    $obj = New-Object psobject -Property $line

    $_c = $toexport.Add($obj)

}

#Path for utility will have to be changed to a more generic location.

$toexport | Export-Csv -Path "C:\OktaExport\user-list.csv" -NoTypeInformation

 

---------------------------------------------------------------------------------------------------------------------------

This question is closed.
Loading
Powershell script to list for users that were deprovisioned over 60 days from current date