-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdisableDevice.gs
More file actions
20 lines (19 loc) · 774 Bytes
/
disableDevice.gs
File metadata and controls
20 lines (19 loc) · 774 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
function disableCB(sernum) {
var serno = sernum;
// Since we provided serial numbers, convert each to device-id
var sernoquery = "id:" + serno;
// Use AdminSDK API to check if the cros device exists. Else the update will fail
var chromebooklist = AdminDirectory.Chromeosdevices.list('my_customer', { query: sernoquery }).chromeosdevices;
if (!chromebooklist) {
} else if (chromebooklist.length !== 1) {
} else {
var id = chromebooklist[0].deviceId;
// For each line, try to update the device with given data, and log the result
try {
var result = AdminDirectory.Chromeosdevices.action({ 'action': 'disable' }, 'my_customer', id);
// If the update fails for some reason, log the error
} catch (err) {
}
}
return [serno];
}