我與我的腳本中提取我的活動目錄CSV導出腳本對Active Directory用戶
Import-Module ActiveDirectory
Get-ADUser -Filter * -properties * | Select SAMaccountname, givenname, surname, DistinguishedName | Export-Csv c: \ users \ administrator \ desktop \ users.csv -notypeinformation -Encoding UTF8
的用戶在這個劇本我使用它返回的CN,該OU和DC中的distinguishedName命令。我的目標是在創建.csv時僅保留第一個OU並刪除其餘部分。的腳本返回什麼
示例:我想要什麼
"SAMaccountname","givenname","surname","DistinguishedName"
"Jean-Yves.R","Jean-Yves","Raymond","CN=Jean-Yves Raymond,OU=Communication,OU=Direction Générale,OU=Elan & Co,OU=Domain Controllers,DC=ELAN-G1,DC=local"
例子:
"SAMaccountname","givenname","surname","DistinguishedName"
"Jean-Yves.R","Jean-Yves","Raymond","Communication"
TY :)
使用濾波器參數,並指定要查詢(通信)的OU。 – DragonZero
...或者只是拆分DN屬性? – Clijsters
你有一個例子可以給我提供過濾器嗎? ty ^^ – Chrys