snap
This commit is contained in:
parent
e79af0ce90
commit
32e5c19230
25
AddUser.ps1
25
AddUser.ps1
@ -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
|
||||||
}
|
}
|
@ -1,7 +1,9 @@
|
|||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param (
|
param (
|
||||||
[string]
|
[string]
|
||||||
$Server
|
$Server,
|
||||||
|
[string]
|
||||||
|
$ProjectName
|
||||||
)
|
)
|
||||||
|
|
||||||
$Projects=$null
|
$Projects=$null
|
||||||
|
Loading…
Reference in New Issue
Block a user