侧边栏壁纸
博主头像
落叶人生博主等级

走进秋风,寻找秋天的落叶

  • 累计撰写 130557 篇文章
  • 累计创建 28 个标签
  • 累计收到 9 条评论
标签搜索

目 录CONTENT

文章目录

域创建组及导出导入组用户

2023-12-21 星期四 / 0 评论 / 0 点赞 / 86 阅读 / 1901 字

直接上脚本(比较简单就不解释了):打开poweshell执行脚本策略powershell中执行set-executionpolicy remotesigned用法: 复制到txt改后缀为ps1 然后拖

直接上脚本(比较简单就不解释了):

打开poweshell执行脚本策略

powershell中执行

set-executionpolicy remotesigned

用法: 复制到txt改后缀为ps1 然后拖到powershell中执行

创建域用户组

##author: Firxiao##date:20160915##usage: create ad groupImport-Module ActiveDirectory##group lists$groups = @("group01""group02""group03") #loopforeach($group in $groups){##NEW-ADGroup –name “Finance” –groupscope Global –path “OU=Offices,DC=Contoso,DC=local”echo "create group $group"NEW-ADGroup –name “$group” –groupscope Global}

导出组用户到csv

##author: Firxiao##date:20160915##usage: export groups member to csv fileImport-Module ActiveDirectory##create path$path = "$(pwd)/Desktop/export"If(!(test-path $path)){New-Item -ItemType Directory -Force -Path $path}##group lists$groups = @("group01""group02""group03") #export loopforeach($group in $groups){echo "export ${group} to $path/${group}.csv"Get-ADGroupMember -identity "${group}" | select SamAccountName| Export-csv -path $path/${group}.csv -NoTypeInformation}

csv用户导入组

##author: Firxiao##date:20160915##usage: import csv groups member to groupImport-Module ActiveDirectory##create path$path = "$(pwd)/Desktop/export"If(!(test-path $path)){echo "Please make sure the csv  dir is exits"}##group lists$groups = @("group01""group02""group03") #export loopforeach($group in $groups){echo "import $path/${group}.csv to ${group}" Import-CSV "$path/${group}.csv" | % { Add-ADGroupMember -Identity "${group}" -Member $_.SamAccountName} }

广告 广告

评论区