55# Cleanup #
66###########
77
8+ # delete-user
89def delete_user (args ):
910 if not args .id :
1011 print_red ("[-] Error: --id argument is required for Delete-User command" )
@@ -27,6 +28,7 @@ def delete_user(args):
2728 print_red (response .text )
2829 print ("=" * 80 )
2930
31+ # delete-group
3032def delete_group (args ):
3133 if not args .id :
3234 print_red ("[-] Error: --id argument is required for Delete-Group command" )
@@ -49,6 +51,7 @@ def delete_group(args):
4951 print_red (response .text )
5052 print ("=" * 80 )
5153
54+ # remove-groupmember
5255def remove_groupmember (args ):
5356 if not args .id :
5457 print_red ("[-] Error: --id groupid,objectid required for Remove-GroupMember command" )
@@ -77,6 +80,7 @@ def remove_groupmember(args):
7780 print_red (response .text )
7881 print ("=" * 80 )
7982
83+ # delete-application
8084def delete_application (args ):
8185 if not args .id :
8286 print_red ("[-] Error: --id argument is required for Delete-Application command" )
@@ -99,6 +103,7 @@ def delete_application(args):
99103 print_red (response .text )
100104 print ("=" * 80 )
101105
106+ # delete-device
102107def delete_device (args ):
103108 if not args .id :
104109 print_red ("[-] Error: --id argument is required for Delete-Device command" )
@@ -121,6 +126,7 @@ def delete_device(args):
121126 print_red (response .text )
122127 print ("=" * 80 )
123128
129+ # wipe-device
124130def wipe_device (args ):
125131 if not args .id :
126132 print_red ("[-] Error: --id argument is required for Wipe-Device command" )
@@ -149,4 +155,28 @@ def wipe_device(args):
149155 else :
150156 print_red (f"[-] Failed to initiate device wipe: { response .status_code } " )
151157 print_red (response .text )
158+ print ("=" * 80 )
159+
160+ # retire-device
161+ def retire_device (args ):
162+ if not args .id :
163+ print_red ("[-] Error: --id argument is required for Retire-Device command" )
164+ return
165+
166+ print_yellow ("[*] Retire-Device" )
167+ print ("=" * 80 )
168+ api_url = f"https://graph.microsoft.com/beta/deviceManagement/managedDevices/{ args .id } /retire"
169+ user_agent = get_user_agent (args )
170+
171+ headers = {
172+ 'Authorization' : f'Bearer { get_access_token (args .token )} ' ,
173+ 'User-Agent' : user_agent
174+ }
175+
176+ response = requests .post (api_url , headers = headers )
177+ if response .ok :
178+ print_green (f"[+] Device retire initiated successfully" )
179+ else :
180+ print_red (f"[-] Failed to initiate device retire: { response .status_code } " )
181+ print_red (response .text )
152182 print ("=" * 80 )
0 commit comments