This commit is contained in:
Karl-Wilfried Zimmer 2024-07-14 19:39:45 +02:00
parent e79af0ce90
commit 32e5c19230
2 changed files with 22 additions and 7 deletions

View File

@ -6,7 +6,9 @@ param (
[string]
$Server,
[string]
$ProjectName
$ProjectName,
[string]
$Type = "RO"
)
$User = $null
@ -29,7 +31,7 @@ if($PSBoundParameters.ContainsKey("Server")){
$User = Get-ADUser -Identity $Identity
}
if($User -eq $null){
if($null -eq $User){
throw "Didn't find the user, aborting"
return
}
@ -40,15 +42,26 @@ if($PSBoundParameters.ContainsKey("Server")){
$Group = . .\GetProjects.ps1
}
if($Group -eq $null){
throw "Can't find Project"
if($null -eq $Group){
throw "Can't find Project, aborting"
return
}
$targeGroup =$null
if($PSBoundParameters.ContainsKey("Server")){
Add-ADGroupMember -Identity -Members $User -Server $Server
$targeGroup = . .\GetRoles.ps1 -Server $Server -ProjectName $ProjectName
} else {
Add-ADGroupMember -Identity -Members $User
$targeGroup = . .\GetRoles.ps1 -ProjectName $ProjectName
}
if($null -eq $Group){
throw "Filter for Type was empty, aborting"
return
}
if($PSBoundParameters.ContainsKey("Server")){
Add-ADGroupMember -Identity $targeGroup -Members $User -Server $Server
} else {
Add-ADGroupMember -Identity $targeGroup -Members $User
}

View File

@ -1,7 +1,9 @@
[CmdletBinding()]
param (
[string]
$Server
$Server,
[string]
$ProjectName
)
$Projects=$null