我需要在G Suite中为批量用户的“自定义”属性中添加值,我已经使用App脚本添加了地址和其他字段,但不知道如何向名为“ 增强型桌面”的自定义属性中添加值安全性”,如下图所示。
使用App脚本要添加的值是:“ un:Windows ”
请求脚本的帮助。
答案 0 :(得分:0)
我一直在研究这个问题,后来才知道首先必须在此处标识custom属性的模式:https://developers.google.com/admin-sdk/directory/v1/reference/users/list一旦完成,就可以使用以下脚本。请确保您在以下脚本中更改了架构。
分别在工作表A,B,C的表单中分别提及“用户电子邮件ID”,“值”,“更新状态”。
function updateCustomE() {
var ss = SpreadsheetApp.openById(""); // Mention ID of the spreadsheet here.
var sheet = ss.getSheetByName(""); // Mention Name of the sheet here.
var values = sheet.getDataRange().getValues();
var fileArray = [["Updation Status"]]
for(i=1; i <values.length; i++)
{
var userKey = values[i][0]
var customValue = values [i][1]
try{
var status = "Value not updated"
var status = AdminDirectory.Users.update({
"customSchemas": {
"Enhanced_desktop_security" : {
"Local_Windows_accounts" : [
{
"type": "custom",
"value": customValue
}
]
}
}
}, userKey);
if (status != "Value not updated"){
status = "Value updated Successfully"
}
}
catch (e) {
Logger.log(e.message)
var status = e.message
}
fileArray.push([status])
}
var range = sheet.getRange(1, 3, fileArray.length, 1).setValues(fileArray)
}