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