-groupname (Read-Host "Enter Group Name")
Get-ADGroupMember -Identity "groupname" -Recursive |
Get-ADUser -Properties mail |
Select-Object Name,mail |
Export-Csv -Path C:\Users\user\OneDrive\groupname.csv
当我运行命令时,在PowerShell中什么也没发生。
答案 0 :(得分:1)
您使用我的建议有误,可以将Read-Host
的输出分配给变量:
$groupname = Read-Host "Enter Group Name"
Get-ADGroupMember -Identity $groupname -Recursive |
Get-ADUser -Properties mail |
Select-Object Name,mail |
Export-Csv -Path C:\Users\user\OneDrive\groupname.csv
或内联使用:
Get-ADGroupMember -Identity (Read-Host "Enter Group Name") -Recursive |
Get-ADUser -Properties mail |
Select-Object Name,mail |
Export-Csv -Path C:\Users\user\OneDrive\groupname.csv