ProjectManagementScripts/NewProject.ps1

35 lines
1.4 KiB
PowerShell
Raw Normal View History

[CmdletBinding()]
param (
[string]
$ProjectName,
[string]
$Server
)
. .\Variables.ps1
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
2024-07-14 16:45:30 +02:00
#$ret = Get-ADGroup $ProjectName -SearchBase $Projects -Server $Server
$acls = . .\AddProjectACL.ps1 -ProjectName $ProjectName -Server $Server
$rs = . .\AddProjectRoles.ps1 -ProjectName $ProjectName -Server $Server
2024-07-14 14:45:53 +02:00
#$ret | Add-ADGroupMember -Members $acl,$r
2024-07-14 16:45:30 +02:00
$acls | ForEach-Object {add-ADGroupMember -Identity $ret -Members $_ -Server $Server}
$rs | ForEach-Object {Add-ADGroupMember -Identity $ret -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
2024-07-14 16:45:30 +02:00
#$ret = Get-ADGroup $ProjectName -SearchBase $Projects
$acls = . .\AddProjectACL.ps1 -ProjectName $ProjectName
$rs = . .\AddProjectRoles.ps1 -ProjectName $ProjectName
2024-07-14 14:45:53 +02:00
#$ret | Add-ADGroupMember -Members $acl,$r
2024-07-14 16:45:30 +02:00
$acls | ForEach-Object {Add-ADGroupMember -Identity $ret -Members $_}
$rs | ForEach-Object {Add-ADGroupMember -Identity $ret -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"