我们可以使用电子表格中的Google Apps脚本从Google管理控制台的REPORT- AUDIT LOG中提取所有报告名称
答案 0 :(得分:0)
您可以使用Admin SDK Reports Service从报告中获取数据。
例如:
/**
* Generates a login activity report for the last week as a spreadsheet. The
* report includes the time, user, and login result.
*/
function generateLoginActivityReport() {
var now = new Date();
var oneWeekAgo = new Date(now.getTime() - 7 * 24 * 60 * 60 * 1000);
var startTime = oneWeekAgo.toISOString();
var endTime = now.toISOString();
var rows = [];
var pageToken;
var page;
do {
page = AdminReports.Activities.list('all', 'login', {
startTime: startTime,
endTime: endTime,
maxResults: 500,
pageToken: pageToken
});
var items = page.items;
if (items) {
for (var i = 0; i < items.length; i++) {
var item = items[i];
var row = [
new Date(item.id.time),
item.actor.email,
item.events[0].name
];
rows.push(row);
}
}
pageToken = page.nextPageToken;
} while (pageToken);
if (rows.length > 0) {
var spreadsheet = SpreadsheetApp.create('G Suite Login Report');
var sheet = spreadsheet.getActiveSheet();
// Append the headers.
var headers = ['Time', 'User', 'Login Result'];
sheet.appendRow(headers);
// Append the results.
sheet.getRange(2, 1, rows.length, headers.length).setValues(rows);
Logger.log('Report spreadsheet created: %s', spreadsheet.getUrl());
} else {
Logger.log('No results returned.');
}
}
调用AdminReports.Activities.list
时,有三个参数:
all
代表域中的所有用户。