This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
|
script:powershell:ad [2021/07/05 10:19] admin created |
script:powershell:ad [2021/08/27 18:20] (current) admin |
||
|---|---|---|---|
| Line 26: | Line 26: | ||
| === Installer le module Active Directory === | === Installer le module Active Directory === | ||
| //Windows 10// | //Windows 10// | ||
| - | Get-WindowsCapability -Name *RSAT* -Online | + | <sxh powershell> |
| + | Get-WindowsCapability -Name *RSAT* -Online | Where-Object Name -Match ActiveDirectory | Add-WindowsCapability -Online | ||
| + | </sxh> | ||
| //Windows Server// | //Windows Server// | ||
| + | <sxh powershell> | ||
| Get-WindowsCapability -Name *ServerManager* -Online | Where-Object State -ne Installed | Add-WindowsCapability -Online | Get-WindowsCapability -Name *ServerManager* -Online | Where-Object State -ne Installed | Add-WindowsCapability -Online | ||
| Get-WindowsCapability -Name *ActiveDirectory* -Online | Where-Object State -ne Installed | Add-WindowsCapability -Online | Get-WindowsCapability -Name *ActiveDirectory* -Online | Where-Object State -ne Installed | Add-WindowsCapability -Online | ||
| - | |||
| import-module activedirectory | import-module activedirectory | ||
| + | </sxh> | ||
| + | === Gestion des groupes === | ||
| + | <sxh powershell> | ||
| + | $KLADMIN = Get-ADGroup -Filter {name -like "*kladmin*"} | ForEach-Object { | ||
| + | (Get-ADGroupMember -Identity $_.name -Recursive) | ForEach-Object { | ||
| + | $ADUserName = $_.name | ||
| + | Get-ADUser -Filter {name -eq $ADUserName} -Properties GivenName,Name,mail | ||
| + | } | ||
| + | } | ||
| + | $KLADMIN | Where-Object Enabled -eq $true | Select-Object GivenName,Name,mail,@{n='Login'; e={$_.UserPrincipalName}} | Export-Csv -Path C:\IT\Kladmin.csv -Force -Encoding UTF8 -Delimiter ',' -NoTypeInformation | ||
| + | </sxh> | ||