mbegan / Okta-PSModule

Okta API Powershell Wrapper Module
Other
102 stars 31 forks source link

oktaPutProfileupdate #11

Closed vikashdaya closed 7 years ago

vikashdaya commented 7 years ago

Unable to use this cmdlet. Can you provide an example of how to use this when multiple profile attributes need to be updated please?

mbegan commented 7 years ago

Oy, i should pull that cmdlet out (along with a few others) there is a good deal of overlapping functionality.

if you are trying to perform an update on a user there are 2 things to keep in mind. Are you performing a partial profile update or full profile update. The consequences of the full profile update is that the attributes that you are sending are treated as authoritative and attributes not specified in the update are nullified.

With that said i have a single function that I use to perform user profile updates with a flag to specific if it is a partial or full update.

oktaUpdateUserProfilebyID

a few examples of usage

partial profile update, adding/updating 2 attributes

oktaUpdateUserProfilebyID -partial -uid 00u9olxnq8R71mG1L0h7 -Profile @{mobilePhone='+1 415 321 9876'; state = 'California'}

Fetch existing user, update existing attributes

#Get the current user
$user = oktaGetUserbyID -userName test1

#change the Mobile and state attributes
$user.profile.mobilePhone = '+1 801 321 9876'
$user.profile.state = 'Utah'

#perform updates of attributes
oktaUpdateUserProfilebyID -uid $user.id -Profile $user.profile

Clear attributes with a partial update

oktaUpdateUserProfilebyID -partial -uid 00u9olxnq8R71mG1L0h7 -Profile @{mobilePhone = $null; state = $null}

Fetch existing user, clear existing attributes

#Get the current user
$user = oktaGetUserbyID -userName test1

#clear the Mobile and state attributes
$user.profile.mobilePhone = $null
$user.profile.state = $null

#perform updates of attributes
oktaUpdateUserProfilebyID -uid $user.id -Profile $user.profile
vikashdaya commented 7 years ago

Thanks Matt