-
Notifications
You must be signed in to change notification settings - Fork 0
/
clearMyAAD.ts
30 lines (27 loc) · 1.08 KB
/
clearMyAAD.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import axios from "axios";
console.log("start");
const token = "";
axios.get("https://graph.microsoft.com/v1.0/myorganization/me/ownedObjects/$/Microsoft.Graph.Application?$select=displayName%2cid%2cappId%2cinfo%2ccreatedDateTime%2ckeyCredentials%2cpasswordCredentials%2cdeletedDateTime&$top=100", {
headers: {
'Authorization': `${token}`
}
}).then(async (response) => {
await Promise.all(response.data.value.map(async (aad: { id: string }) => {
console.log(`deleting ${aad.id}`);
await axios.delete(`https://graph.microsoft.com/v1.0/myorganization/applications/${aad.id}`, {
headers: {
'Authorization': `${token}`
}
});
}));
await Promise.all(response.data.value.map(async (aad: { id: string }) => {
console.log(`permanently deleting ${aad.id}`);
await axios.delete(`https://graph.microsoft.com/v1.0/directory/deletedItems/${aad.id}`, {
headers: {
'Authorization': `${token}`
}
});
}));
}).catch((error) => {
console.log(error.message);
});