ProjectManagementScripts/NewProject.ps1

39 lines
1.5 KiB
PowerShell
Raw Normal View History

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