corrected casts
This commit is contained in:
parent
2bd7340a85
commit
f701fb282f
@ -11,8 +11,8 @@ param (
|
|||||||
$Type = "RO"
|
$Type = "RO"
|
||||||
)
|
)
|
||||||
|
|
||||||
[ADUser]$User = $null
|
$User = $null
|
||||||
[ADGroup]$Group = $null
|
$Group = $null
|
||||||
|
|
||||||
|
|
||||||
if(!$PSBoundParameters.ContainsKey("ProjectName")){
|
if(!$PSBoundParameters.ContainsKey("ProjectName")){
|
||||||
@ -61,7 +61,7 @@ if($null -eq $Group){
|
|||||||
}
|
}
|
||||||
|
|
||||||
if($PSBoundParameters.ContainsKey("Server")){
|
if($PSBoundParameters.ContainsKey("Server")){
|
||||||
Add-ADGroupMember -Identity $targeGroup -Members $User -Server $Server
|
Add-ADGroupMember -Identity $targeGroup -Members $Identity -Server $Server
|
||||||
} else {
|
} else {
|
||||||
Add-ADGroupMember -Identity $targeGroup -Members $User
|
Add-ADGroupMember -Identity $targeGroup -Members $Identity
|
||||||
}
|
}
|
@ -1,67 +0,0 @@
|
|||||||
[CmdletBinding()]
|
|
||||||
param (
|
|
||||||
|
|
||||||
[string]
|
|
||||||
$Identity,
|
|
||||||
[string]
|
|
||||||
$Server,
|
|
||||||
[string]
|
|
||||||
$ProjectName,
|
|
||||||
[string]
|
|
||||||
$Type = "RO"
|
|
||||||
)
|
|
||||||
|
|
||||||
[ADUser]$User = $null
|
|
||||||
[ADGroup]$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($null -eq $User){
|
|
||||||
throw "Didn't find the user, aborting"
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if($PSBoundParameters.ContainsKey("Server")){
|
|
||||||
$Group = . .\GetProjects.ps1 -Server $Server
|
|
||||||
} else {
|
|
||||||
$Group = . .\GetProjects.ps1
|
|
||||||
}
|
|
||||||
|
|
||||||
if($null -eq $Group){
|
|
||||||
throw "Can't find Project, aborting"
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
$targeGroup =$null
|
|
||||||
|
|
||||||
if($PSBoundParameters.ContainsKey("Server")){
|
|
||||||
$targeGroup = . .\GetRoles.ps1 -Server $Server -ProjectName $ProjectName
|
|
||||||
} else {
|
|
||||||
$targeGroup = . .\GetRoles.ps1 -ProjectName $ProjectName
|
|
||||||
}
|
|
||||||
|
|
||||||
if($null -eq $Group){
|
|
||||||
throw "Filter for Type was empty, aborting"
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if($PSBoundParameters.ContainsKey("Server")){
|
|
||||||
$targeGroup | ForEach-Object {Add-ADGroupMember -Identity $_ -Members $User -Server $Server}
|
|
||||||
} else {
|
|
||||||
$targeGroup | ForEach-Object {Add-ADGroupMember -Identity $_ -Members $User}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user