added adduser commandlet, made getters filterable
This commit is contained in:
parent
87e2a8ca79
commit
e79af0ce90
54
AddUser.ps1
Normal file
54
AddUser.ps1
Normal 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
|
||||||
|
}
|
@ -1,7 +1,9 @@
|
|||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param (
|
param (
|
||||||
[string]
|
[string]
|
||||||
$Server
|
$Server,
|
||||||
|
[string]
|
||||||
|
$ProjectName
|
||||||
)
|
)
|
||||||
|
|
||||||
$Projects=$null
|
$Projects=$null
|
||||||
@ -11,4 +13,8 @@ if($PSBoundParameters.ContainsKey("Server")){
|
|||||||
$Projects = . .\GetProjects.ps1
|
$Projects = . .\GetProjects.ps1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($PSBoundParameters.ContainsKey("ProjectName")){
|
||||||
|
$Projects = $Projects | Where-Object Name -Match $ProjectName
|
||||||
|
}
|
||||||
|
|
||||||
return $Projects | Get-ADGroupMember | Where-Object Name -Match "ACL.*"
|
return $Projects | Get-ADGroupMember | Where-Object Name -Match "ACL.*"
|
@ -11,4 +11,8 @@ if($PSBoundParameters.ContainsKey("Server")){
|
|||||||
$Projects = . .\GetProjects.ps1
|
$Projects = . .\GetProjects.ps1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($PSBoundParameters.ContainsKey("ProjectName")){
|
||||||
|
$Projects = $Projects | Where-Object Name -Match $ProjectName
|
||||||
|
}
|
||||||
|
|
||||||
return $Projects | Get-ADGroupMember | Where-Object Name -Match "GR.*"
|
return $Projects | Get-ADGroupMember | Where-Object Name -Match "GR.*"
|
Loading…
Reference in New Issue
Block a user