internal/functions/Method14.ps1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
Function Method14 { <# .SYNOPSIS Get user's Delegates information .DESCRIPTION Get user's Delegates information .EXAMPLE PS C:\> Method14 Get user's Delegates information #> [CmdletBinding()] param( # Parameters ) $statusBar.Text = "Running..." # Create a mailbox object that represents the user in case we are impersonating. $mailbox = New-Object Microsoft.Exchange.WebServices.Data.Mailbox($email); # Call the GetDelegates method to get the delegates of the mailbox object. $delegates = $service.GetDelegates($mailbox , $true) $Collection = @() foreach( $Delegate in $delegates.DelegateUserResponses ) { $Obj = "" | Select-Object EmailAddress,Inbox,Calendar,Contacts,Tasks,Notes,Journal,MeetingMessages,ViewPrivateItems $Obj.EmailAddress = $Delegate.DelegateUser.UserId.PrimarySmtpAddress $Obj.Inbox = $Delegate.DelegateUser.Permissions.InboxFolderPermissionLevel $Obj.Calendar = $Delegate.DelegateUser.Permissions.CalendarFolderPermissionLevel $Obj.Contacts = $Delegate.DelegateUser.Permissions.ContactsFolderPermissionLevel $Obj.Tasks = $Delegate.DelegateUser.Permissions.TasksFolderPermissionLevel $Obj.Notes = $Delegate.DelegateUser.Permissions.NotesFolderPermissionLevel $Obj.Journal = $Delegate.DelegateUser.Permissions.JournalFolderPermissionLevel $Obj.ViewPrivateItems = $Delegate.DelegateUser.ViewPrivateItems $Obj.MeetingMessages = $Delegate.DelegateUser.ReceiveCopiesOfMeetingMessages $Collection += $Obj } $array = New-Object System.Collections.ArrayList [int]$i = 0 foreach ( $Del in $Collection ) { $i++ $output = $Del | Select-Object EmailAddress, Inbox, Calendar, Tasks, Notes, Journal, ViewPrivateItems, MeetingMessages $array.Add($output) } $dgResults.datasource = $array $dgResults.AutoResizeColumns() $dgResults.Visible = $True $txtBoxResults.Visible = $False $PremiseForm.refresh() $statusBar.Text = "Ready. Amount of Delegates: $i" Write-PSFMessage -Level Host -Message "Task finished succesfully" -FunctionName "Method 14" } |