diff --git a/AddUser.ps1 b/AddUser.ps1 new file mode 100644 index 0000000..8ab4786 --- /dev/null +++ b/AddUser.ps1 @@ -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 +} \ No newline at end of file diff --git a/GetACLs.ps1 b/GetACLs.ps1 index ec04169..25aad83 100644 --- a/GetACLs.ps1 +++ b/GetACLs.ps1 @@ -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.*" \ No newline at end of file diff --git a/GetRoles.ps1 b/GetRoles.ps1 index dc11893..239158a 100644 --- a/GetRoles.ps1 +++ b/GetRoles.ps1 @@ -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.*" \ No newline at end of file