added adduser commandlet, made getters filterable

This commit is contained in:
Karl-Wilfried Zimmer 2024-07-14 19:32:03 +02:00
parent 87e2a8ca79
commit e79af0ce90
3 changed files with 65 additions and 1 deletions

54
AddUser.ps1 Normal file
View File

@ -0,0 +1,54 @@
[CmdletBinding()]
param (
[string]
$Identity,
[string]
$Server,
[string]
$ProjectName
)
$User = $null
$Group = $null
if(!$PSBoundParameters.ContainsKey("ProjectName")){
throw "ProjectName Parameter not specified, aborting"
return
}
if(!$PSBoundParameters.ContainsKey("Identity")){
throw "Identity Parameter not specified, aborting"
return
}
if($PSBoundParameters.ContainsKey("Server")){
$User = Get-ADUser -Server $Server -Identity $Identity
} else {
$User = Get-ADUser -Identity $Identity
}
if($User -eq $null){
throw "Didn't find the user, aborting"
return
}
if($PSBoundParameters.ContainsKey("Server")){
$Group = . .\GetProjects.ps1 -Server $Server
} else {
$Group = . .\GetProjects.ps1
}
if($Group -eq $null){
throw "Can't find Project"
return
}
$targeGroup =$null
if($PSBoundParameters.ContainsKey("Server")){
Add-ADGroupMember -Identity -Members $User -Server $Server
} else {
Add-ADGroupMember -Identity -Members $User
}

View File

@ -1,7 +1,9 @@
[CmdletBinding()]
param (
[string]
$Server
$Server,
[string]
$ProjectName
)
$Projects=$null
@ -11,4 +13,8 @@ if($PSBoundParameters.ContainsKey("Server")){
$Projects = . .\GetProjects.ps1
}
if($PSBoundParameters.ContainsKey("ProjectName")){
$Projects = $Projects | Where-Object Name -Match $ProjectName
}
return $Projects | Get-ADGroupMember | Where-Object Name -Match "ACL.*"

View File

@ -11,4 +11,8 @@ if($PSBoundParameters.ContainsKey("Server")){
$Projects = . .\GetProjects.ps1
}
if($PSBoundParameters.ContainsKey("ProjectName")){
$Projects = $Projects | Where-Object Name -Match $ProjectName
}
return $Projects | Get-ADGroupMember | Where-Object Name -Match "GR.*"