Powershell脚本,列出禁用其经理帐户的所有用户

时间:2015-10-01 09:18:32

标签: powershell

我已经为组而不是用户修改了相同的脚本,如下所示,我没有得到任何显示

$ adgroups = get-adgroup -searchbase“ou = test,dc = domain,dc = com”-filter * -Properties *

Foreach($ adgroups中的$ adgroup)

{

if($ adgroup.manager -ne $ null)

{

    }

}

write-host“$($ adgroup.SamAccountName),$($ manager.SamAccountName)” - Path“C:\ Users \ test \ Desktop \ log.csv”

#import "AsyncImageView.h"

NSString *urlString = friendData[@"picture"][@"data"][@"url"];

AsyncImageView *DescimageRight = [[AsyncImageView alloc]initWithFrame:CGRectMake(4,4,146,146)];
DescimageRight.contentMode = UIViewContentModeScaleAspectFill;
DescimageRight.backgroundColor=[UIColor clearColor];
DescimageRight.tag=999;
DescimageRight.imageURL=[NSURL URLWithString:urlString];
[self.view addSubview:DescimageRight];

}

1 个答案:

答案 0 :(得分:0)

这应该可行,它可以编写得更好但我想用您开始的代码计算。

$adusers = get-aduser -searchbase "ou=test,dc=domain,dc=com" -filter * -Properties manager

Foreach($aduser in $adusers)
{
    if($aduser.manager -ne $null)
    {
        $manager = Get-ADUser -filter {Distinguishedname -eq $aduser.manager}
        if($($manager.enabled) -eq $false)
        {
            Add-Content -Value "$($aduser.SamAccountName),$($manager.SamAccountName)" -Path "C:\Users\test\Desktop\log.csv"
        }
    }
}