当前位置:网站首页 > 更多 > 玩电脑 > 正文

[玩转系统] PowerShell:我用于记录和监控 Active Directory 的 10 个最常用命令

作者:精品下载站 日期:2024-12-14 07:16:43 浏览:12 分类:玩电脑

PowerShell:我用于记录和监控 Active Directory 的 10 个最常用命令


在这篇文章中,我想介绍用于记录和监控 Active Directory 域服务的 10 个最重要的命令。

列出所有域控制器

Get-ADDomainController -Filter * | Format-List Name,Ipv4Address,IPv6Address,OperatingSystem

[玩转系统] PowerShell:我用于记录和监控 Active Directory 的 10 个最常用命令

列出所有全局编录服务器

Get-ADDomainController -Discover -Service "GlobalCatalog"

[玩转系统] PowerShell:我用于记录和监控 Active Directory 的 10 个最常用命令

列出所有操作主机角色 (FSMO)

森林范围内的角色

Get-ADForest | Format-Table SchemaMaster,DomainNamingmaster

[玩转系统] PowerShell:我用于记录和监控 Active Directory 的 10 个最常用命令

域范围内的角色

Get-ADDomain | Format-List pdc*,infra*,rid*

[玩转系统] PowerShell:我用于记录和监控 Active Directory 的 10 个最常用命令

我不得不承认:netdom 查询 fsmo 要简单得多 ?

netdom query fsmo

[玩转系统] PowerShell:我用于记录和监控 Active Directory 的 10 个最常用命令

链接:Active Directory FSMO Rollen (Betriebsmaster)

监控 Active Directory 登录

登录成功

我正在寻找用户“Petra”的登录信息。请注意,需要查找所有域控制器上的所有事件日志。如果您不会说德语,请不要对德语屏幕截图感到困惑。注意登录类型“Anmeldetyp”。该值为 2 - 用户已登录到域。

Get-EventLog -LogName Security -InstanceId 4624 | Where-Object Message -match "petra" | Format-Table TimeGenerated,Message -AutoSize -Wrap

[玩转系统] PowerShell:我用于记录和监控 Active Directory 的 10 个最常用命令

[玩转系统] PowerShell:我用于记录和监控 Active Directory 的 10 个最常用命令

登录失败

Get-EventLog -LogName Security -InstanceId 4771 | Where-Object Message -match "petra" | Format-Table TimeGenerated,Message -AutoSize -Wrap

[玩转系统] PowerShell:我用于记录和监控 Active Directory 的 10 个最常用命令

请注意错误代码 0x18。用户提供了错误的密码。

[玩转系统] PowerShell:我用于记录和监控 Active Directory 的 10 个最常用命令

有关 Active Directory 登录的更多信息,请参阅我的德语博客文章:Active Directory Anmeldungen überwachen

查找孤立的计算机帐户

查找一年内未登录域的所有计算机帐户

Get-ADComputer -Filter * -Properties operatingsystem,lastlogondate | Where-Object {($_.operatingsystem -notlike "*Server*") -and ($_.lastlogondate -le ((Get-Date).adddays(-365)))} | Sort-Object Lastlogondate | Format-Table Name,Lastlogondate

[玩转系统] PowerShell:我用于记录和监控 Active Directory 的 10 个最常用命令

链接(德语):Active Directory:Verwaiste(无效)Computerkonten finden

查找孤立用户帐户

查找一年内未登录域的所有用户帐户

Get-ADUser -Filter * -Properties LastLogonDate | ? {$_.lastlogondate -ne $null -and $_.lastlogondate -le ((get-date).adddays(-365))} | Format-List Name,LastLogonDate

链接(德语):Active Directory:Inaktive Benutzer mit Get-ADUser suchen

查找孤立的组策略

要查找尚未链接到组织单位的所有组策略,请运行

Get-GPO -All | % {
 If ( $_ | Get-GPOReport -ReportType XML | Select-String -NotMatch "<LinksTo>" ) {
 Write-Host $_.DisplayName, $_.CreationTime, $_.Modificationtime 
 }
 }

链接(德语):Active Directory:Suche nach inaktiven, nicht verknüpften Gruppenrichtlinien

查找所有 Active Directory 联系人

Get-ADObject -Filter 'objectClass -eq "contact"' -Properties CN | Format-List CN

[玩转系统] PowerShell:我用于记录和监控 Active Directory 的 10 个最常用命令

链接:PowerShell:查找 Active Directory 联系人

列出加入域的计算机的硬件信息

使用 Set-Content 或变量获取所有计算机的列表。

(Get-ADComputer -Filter *).Name | Set-Content C:\Computers.txt

然后运行 Get-WMIObject 并保存用户友好的输出。

Get-WMIObject -ComputerName (Get-Content C:\Computers.txt) -Class Win32_Computersystem -ErrorAction SilentlyContinue | ConvertTo-Html Name,TotalPhysicalMemory -Title (Get-Date) -Body "RAM Liste aller Computer" | Set-Content C:\Ram.htm

[玩转系统] PowerShell:我用于记录和监控 Active Directory 的 10 个最常用命令

链接(德语):WMI:Hardwarekonfiguration aller Domänen-Computer abrufen und speichern

搜索 Active Sync 用户

公平地说,这与交换有关。但 Exchange 与 Active Directory 相关。因此,让我们搜索 Exchange Active Sync 用户。

Get-CASMailbox -Filter {hasactivesyncdevicepartnership -eq $true -and -not displayname -like "CAS_*"} | Get-Mailbox | Format-List name

[玩转系统] PowerShell:我用于记录和监控 Active Directory 的 10 个最常用命令

链接(德语):Exchange Active Sync Benutzer anzeigen

更多信息

如果您想使用 PowerShell 安装域控制器,请查看我的帖子 PowerShell:如何使用服务器核心安装域控制器。

您需要 登录账户 后才能发表评论

取消回复欢迎 发表评论:

关灯