我正在尝试使用PowerShell语法创建一个AD组名列表,然后我可以继续循环并处理它们。 一个命名组的工作代码是:
/
他们将此AD组拆分为8个子组,因此现在要求
deploy
我正在努力的 <modelVersion>4.0.0</modelVersion>
<groupId>es.saljuama</groupId>
<artifactId>geoserver</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>geoserver</name>
<description>Geoserver demo project</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.7</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<profiles>
<profile>
<!-- Using this profile for my local machine, just the app using and embedded tomcat, with devtools, since i'm not sure if you want to make your app interact with the geoserver or not. -->
<id>local</id>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>openshift</id>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<finalName>geoserver</finalName>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<outputDirectory>webapps</outputDirectory>
<warName>ROOT</warName>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
。
答案 0 :(得分:2)
尝试以下方法:
$GroupList = "My_Group_Name1","My_Group_Name2","My_Group_Name3","My_Group_Name4"
$GroupMembers = @()
$GroupList | ForEach-Object {
$GroupMembers += (Get-AdGroup -identity $_ | Get-ADGroupMember | select -expandproperty name)
}
$GroupMembers
我不会使用一个字符串来存储所有组名,尝试使用字符串数组,然后您将不需要使用split命令。上面的代码将采用一组组名,并将它们的memebrs添加到变量$GroupMembers
。
答案 1 :(得分:0)
您需要遍历您的群组。
foreach($ grouplist中的$ group){
your code here
}
答案 2 :(得分:0)
改变这个:
$Groups = $GroupList.split(",");
$Groups = (Get-AdGroup -identity ***each group member of $Groups*** |
select name -expandproperty name)
进入这个:
$Groups = $GroupList.Split(",") | Get-ADGroupMember |
Select-Object -ExpandProperty Name
更好的是,立即将$GroupList
定义为数组(建议为@Chard),因此您不需要首先拆分字符串:
$GroupList = 'My_Group_Name1', 'My_Group_Name2', 'My_Group_Name3',
'My_Group_Name4'
$Groups = $GroupList | Get-ADGroupMember | Select-Object -Expand Name
答案 3 :(得分:0)
$Grouplist = @(
"group1",
"group2"
)
foreach($group in $Grouplist){
Get-ADGroupMember -identity $group |select name -expandproperty name
}