skip in powershell

0

Hi, I'm new to programming, but I'm using PowerSHELL, and I want to make a script showing the permissions of a user.

I already achieve it only that it shows me all the permits and they can not see all of them

Function Get-UserPermission
{
  param(
  [string]$Identity)

  Get-ADUser -Filter * -Properties DisplayName,memberof  -SearchBase 
  "OU=Reynosa,OU=HMD,OU=AMR,OU=MAC,DC=emrsn,DC=org" |
  where {$_.samAccountName -match $Identity} | format-table DisplayName, Memberof 
}
  

PS C: > Get-UserPermission -Identity karina

     

DisplayName Memberof

     

----------- -------- Garcia, Karina {CN = HM REY HALLFAMEDASH, OU = HM REY File   Shares, OU = Groups, OU = Reynosa, OU = HMD, OU = AMR, OU = MAC, DC = emrsn, DC = org, C ...   Gaspar, Karina [COMRES / HM / REY] {CN = EC MDM Global   VelocityEHS, OU = Groups, OU = STL, OU = Corporate, OU = AMR, OU = Corporate, DC = emrsn, DC = org,   CN = DL All ...

but I can not see all the permissions

How can I take a jump x each, ??

    
asked by user109769 06.12.2018 в 22:54
source

1 answer

0

A possible solution is to separate the information and then expand the values of Memberof :

Function Get-UserPermission
{
  param(
  [string]$Identity)

  Write-host "Usuario: " -NoNewline 
  Write-host $Identity
  Write-host "-------------"
  Get-ADUser -Filter * -Properties DisplayName,memberof  -SearchBase 
  "OU=Reynosa,OU=HMD,OU=AMR,OU=MAC,DC=emrsn,DC=org" |
  where {$_.samAccountName -match $Identity} | 
  select Memberof -ExpandProperty Memberof | Format-Table

}

The result would be something like this:

Usuario: vsilva
-------------
CN=Admins RODC,OU=Grupos,OU=empresa,DC=dominio,DC=local
CN=VMM_Admins,OU=SCVMM Grupos,OU=SCVMM,OU=SystemCenter,OU=empresa,DC=dominio,DC=local
CN=Admins_Sharepoint,OU=Permisos Sharepoint,OU=empresa,DC=dominio,DC=local
CN=Administradores de empresa,OU=Grupos,OU=empresa,DC=dominio,DC=local
CN=Administradores de organización,CN=Users,DC=dominio,DC=local
CN=Usuarios de escritorio remoto,CN=Builtin,DC=dominio,DC=local
CN=Organization Management,OU=Microsoft Exchange Security Groups,DC=dominio,DC=local

I understand that there are better ways, but I think that solving the problem with that small change is more than enough.

    
answered by 07.12.2018 в 14:15