Add bulk wipe
This commit is contained in:
parent
4721569c5d
commit
b24a5bb612
6 changed files with 119 additions and 2 deletions
67
wipebulk.js
Normal file
67
wipebulk.js
Normal file
|
@ -0,0 +1,67 @@
|
|||
#!/usr/bin/env node
|
||||
import fs from "fs";
|
||||
import { info } from "./gum.js";
|
||||
import { authenticate, bulk, call } from "./mosyle.js";
|
||||
|
||||
let serialsTxt = "";
|
||||
for await (const chunk of process.stdin) {
|
||||
serialsTxt += chunk;
|
||||
}
|
||||
|
||||
const serials = serialsTxt.split("\n").filter(Boolean);
|
||||
|
||||
const accessToken = process.env.MOSYLE_TOKEN;
|
||||
|
||||
info("Authenticating...");
|
||||
const token = await authenticate(
|
||||
process.env.MOSYLE_USER,
|
||||
process.env.MOSYLE_PASSWORD,
|
||||
accessToken,
|
||||
);
|
||||
|
||||
info("Getting devices...");
|
||||
const devices = await call(
|
||||
"/listdevices",
|
||||
{ accessToken, serial_number: serials, options: { os: "ios" } },
|
||||
token,
|
||||
)
|
||||
.then((res) => res.json())
|
||||
.then((j) =>
|
||||
j.status == "OK"
|
||||
? j.response.devices.map((d) => d.deviceudid)
|
||||
: console.error(j),
|
||||
);
|
||||
|
||||
info("Changing to limbo and wiping...");
|
||||
console.log(
|
||||
await (
|
||||
await bulk(
|
||||
{
|
||||
accessToken,
|
||||
elements: [
|
||||
{
|
||||
operation: "change_to_limbo",
|
||||
devices,
|
||||
},
|
||||
{
|
||||
operation: "wipe_devices",
|
||||
devices,
|
||||
options: {
|
||||
PreserveDataPlan: "true",
|
||||
DisallowProximitySetup: "true",
|
||||
RevokeVPPLicenses: "true",
|
||||
EnableReturnToService: "true",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
token,
|
||||
)
|
||||
).text(),
|
||||
);
|
||||
|
||||
await info(
|
||||
"To do more, paste this comma-separated list of serial numbers into the Mosyle search box:",
|
||||
);
|
||||
|
||||
console.log(serials.join(","));
|
Loading…
Add table
Add a link
Reference in a new issue