Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. $aplip = "192.168.1.100"
  2. $pass = "mysupersecretpassword"
  3. $username = "administrator"
  4. $SecurePassword = ConvertTo-SecureString $Pass -AsPlainText -Force
  5. $Credential = New-Object System.Management.Automation.PSCredential ($Username, $SecurePassword)
  6. $websession = Connect-alsession -aplip $aplip -Credential $Credential -Verbose
  7.  
  8. #Final Array
  9. $final = @()
  10.  
  11. #Get Directory
  12. $dir = Get-ALDirectory -websession $websession|where{$_.name -eq "Lab"}
  13.  
  14. #Get LDAP Users that have authenticated to ELM
  15. $Users = Get-ALUserList -websession $websession -junctionid $dir.id|Where-Object {$_.DirectoryId.type -eq "UserId" -and $_.DirectoryId.UnideskId -ne 0}
  16.  
  17.  
  18. #Iterate user list
  19. foreach ($user in $Users)
  20. {
  21. #Get User Detail
  22. $userdetail = Get-ALUserDetail -websession $websession -junctionid $dir.id -ldapguid $user.DirectoryId.LdapGuid -dn $user.DirectoryId.LdapDN -id $user.DirectoryId.UnideskId
  23.  
  24. #Get Groups User is member of
  25. $groups = Get-ALUserGroupMembership -websession $websession -junctionid $dir.id -id $User.DirectoryId.UnideskId -ldapguid $user.FullId.LdapGuid -ldapdn $user.FullId.LdapDN -sid $userdetail.FullId.sid
  26.  
  27. #build group array for search
  28. $groupids = @()
  29. $groups|%{$groupids += $_.DirectoryId.UnideskId}
  30. #add user to group array
  31. $groupids += $User.DirectoryId.UnideskId
  32.  
  33. #Get Apps that User and Groups are assigned to
  34. $apps = Get-ALUserAssignment -websession $websession -id $groupids
  35.  
  36. #Iterate each app found
  37. foreach ($app in $apps)
  38. {
  39. #Create PS object
  40. $object = [PSCustomObject] @{
  41. 'UserName' = $user.LoginName
  42. 'UserDN' = $user.FullId.LdapDN
  43. 'AppLayer' = $app.LayerName;
  44. 'Revision' = $app.CurrentRevision;
  45. 'AssignedVia' = $app.AssignedVia;
  46. 'AssignedViaDisplayName' = $app.AssignedViaDisplayName}
  47. #Add to return object
  48. $final += $object
  49. }
  50.  
  51. }
  52. #Output object
  53. $final|ft -AutoSize
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement