[CmdletBinding()] param ( [string] $ProjectName, [string] $Server ) . .\Variables.ps1 $ret $acl $r if($PSBoundParameters.ContainsKey("ProjectName")){ if($PSBoundParameters.ContainsKey("Server")){ $ret = New-ADGroup -Path $Projects -Server $Server -Name $ProjectName -GroupCategory Security -GroupScope Global -PassThru $ret = Get-ADGroup $ProjectName -SearchBase $Projects -Server $Server $acl = . .\AddProjectACL.ps1 -ProjectName $ProjectName -Server $Server $r = . .\AddProjectRoles.ps1 -ProjectName $ProjectName -Server $Server #$ret | Add-ADGroupMember -Members $acl,$r $acl | ForEach-Object {add-ADGroupMember -Identity "$ret.DistinguishedName" -Members $_ -Server $Server} $r | ForEach-Object {Add-ADGroupMember -Identity "$ret.DistinguishedName" -Members $_ -Server $Server} } else { $ret = New-ADGroup -Path $Projects -Name $ProjectName -GroupCategory Security -GroupScope Global -PassThru $ret = Get-ADGroup $ProjectName -SearchBase $Projects $acl = . .\AddProjectACL.ps1 -ProjectName $ProjectName $r = . .\AddProjectRoles.ps1 -ProjectName $ProjectName #$ret | Add-ADGroupMember -Members $acl,$r $acl | ForEach-Object {Add-ADGroupMember -Identity "$ret.DistinguishedName" -Members $_} $r | ForEach-Object {Add-ADGroupMember -Identity "$ret.DistinguishedName" -Members $_} } return $ret } throw "ProjectName parameter needs to be set"