且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将所有ADUsers包含在CSV文件中

更新时间:2023-09-19 15:33:04

ActiveDirectory模块cmdlet。这么容易。看起来像这样:

Use the ActiveDirectory module cmdlets. So much easier. Looks something like this:

$path = ".\Users.csv"
Get-ADUser -Filter * | 
  Select-Object cn, mail, samaccountname, distinguishedname |
  Export-Csv -Path $Path

根据您的PowerShell版本,您可能需要手动导入模块。

Depending on your version of PowerShell, you may need to manually import the module.

Import-Module ActiveDirectory