Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell 用于提取用户所属广告组列表的脚本_Powershell - Fatal编程技术网

Powershell 用于提取用户所属广告组列表的脚本

Powershell 用于提取用户所属广告组列表的脚本,powershell,Powershell,我有以下工作脚本: # This script Extracts , Active Drirectory Groups the user is currently a memeber-of $users = Get-Content "C:\powershell\Permmisions\users.txt" foreach ($user in $users){ Get-ADPrincipalGroupMembership $user | select name | Out-File C:\Powe

我有以下工作脚本:

# This script Extracts , Active Drirectory Groups the user is currently a memeber-of
$users = Get-Content "C:\powershell\Permmisions\users.txt"
foreach ($user in $users){ Get-ADPrincipalGroupMembership $user | select name | Out-File C:\Powershell\1.csv }
问题是,在创建的CSV文件中,每一行都包含一个组名, 包含我必须删除的额外空格字符。有没有一种方法可以将以下信息提取到CSV或TXT,而不需要额外的空间


谢谢。

您只需将输出文件替换为导出csv,如下所示:

# This script Extracts , Active Drirectory Groups the user is currently a memeber-of
$users = Get-Content "C:\powershell\Permmisions\users.txt"
foreach ($user in $users){ 
    Get-ADPrincipalGroupMembership $user | select name | export-csv C:\Powershell\1.csv -notypeinfo -append
}

使用导出csv而不是输出文件