我最近完成了一个新的PowerShell脚本,该脚本将CSV导入到我们的Active Directory中,它将根据需要创建,禁用和启用帐户。我现在正尝试使用GAM模仿G Suite的此解决方案。我将以下命令用于AD来设置一个布尔值,可以根据需要在整个脚本中使用它。
$exist = [bool]($account=([adsisearcher]"(samaccountname=$($user.samaccountname))").findone())
GAM不会提供这样的简单检查,但是,我可以触发命令以内联有关帐户的信息来进行响应。
是否可以扫描命令提供的响应?例如...
命令:
gam whatis testuser8 nolicenses nogroups noaliases noschemas
回复:
test...@rdschool.org is a user User: test...@rdschool.org First Name: Test Last Name: User8 Is a Super Admin: False Is Delegated Admin: False 2-step enrolled: False 2-step enforced: False Has Agreed to Terms: False IP Whitelisted: False Account Suspended: True Suspension Reason: ADMIN Must Change Password: False Google Unique ID: 107453623127020962025 Customer ID: C03kt1m66 Mailbox is setup: True Included in GAL: True Creation Time: 2018-06-11T14:57:36.000Z Last login time: Never Google Org Unit Path: /Test/Vault
我如何使用PowerShell解释响应中包含“暂停的帐户:True”,以便我可以采取行动?