Powershell管理 GSuite 系统

豆子最近有个新的项目 须要迁移500多个GSuite的帐号到 Office365里面。PowerShell Gallery已经提供了相关的Gsuite 的模块进行下载。可是Google Admin初始化的配置比Office365 麻烦多了,并且网上的wiki资料过期了,界面彻底对应不上。shell

官网说明,可是这个资料是去年更新的,界面不少地方都对不上号了
https://psgsuite.io/安全

下面看看如何实现。app

首先下载PS的模块,微软半年前升级他的安全标准以后,PS5 默认的 Tls1 已经不支持了,所以我须要手动指定安全协议是 tls2ide

Powershell管理 GSuite 系统

登录 Google API测试

Powershell管理 GSuite 系统

根据提示下一步ui

Powershell管理 GSuite 系统

选择 service account3d

Powershell管理 GSuite 系统

建立新的 service account
Powershell管理 GSuite 系统code

输入相关信息blog

Powershell管理 GSuite 系统

Role 选择 Owner
Powershell管理 GSuite 系统get

Done
Powershell管理 GSuite 系统

Add Key
Powershell管理 GSuite 系统

选择 P12的格式下载
Powershell管理 GSuite 系统

记录一下帐号

Powershell管理 GSuite 系统

Enable service account
Powershell管理 GSuite 系统

而后去 GSuite 的 Security 里面 添加一个新的app
Powershell管理 GSuite 系统

而后在 SSO里面查看一下customer id

Powershell管理 GSuite 系统

最后链接一下
Powershell管理 GSuite 系统

测试一下

$groups=Get-GSGroup 
foreach($group in $groups){
    #$group | select
    $email=$group.Email
    write-host $name -ForegroundColor Cyan
    Get-GSGroupMember -Identity $email | select Group, Email, kind, status | ft -AutoSize
}

$users=Get-GSUser -Filter *

$users | measure

$date=(get-date).AddDays(-30)

$demo=$users | Where-Object {$_.LastLoginTime -lt $date} 

$demo | select user,creationtime, lastlogintime | sort lastlogintime -Descending

Powershell管理 GSuite 系统

相关文章
相关标签/搜索