Skip to content

Instantly share code, notes, and snippets.

@sean-horn
Created March 5, 2015 17:24
Show Gist options
  • Save sean-horn/754cf57b1b9a39c6d7b0 to your computer and use it in GitHub Desktop.
Save sean-horn/754cf57b1b9a39c6d7b0 to your computer and use it in GitHub Desktop.
cleanup-org-invites-api knife exec script
# OC-11643
# OC-11644
# You can use this script by running `knife exec`
# knife exec cleanup_orphaned_invites_via_api.rb -s https://CHEF_SERVER_URL/organizations/ORG_NAME
invites = api.get('association_requests')
orphaned_invites = invites.select { |invite| invite['username'].nil? }
orphaned_invites.each do |invite|
api.delete("association_requests/#{invite['id']}")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment