forked from hsmalley/Powershell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Search_Mailbox.ps1
22 lines (19 loc) · 885 Bytes
/
Search_Mailbox.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#region Setup
#Connect to Exchange with different credentials
$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://EXCHANGESERVER/PowerShell/ -Authentication Kerberos -Credential $UserCredential
Import-PSSession $Session -AllowClobber
<#
Function Get-Mails {
#Setup Variables
$User1 = Read-Host -Prompt "Enter User ID to search"
$User2 = Read-Host -Prompt "Enter User to send mail to"
$Search = Read-Host -Prompt "Enter Subject to search for"
#search mailbox with USER and Subject of Yummy Pies then create a folder in user's mailbox. To search for keywoards remove "Subject"
Search-Mailbox -Identity "$User1" -SearchQuery "Subject:$Search" -TargetMailbox "$User2" -TargetFolder "$Search"
$Again = Read-Host -Prompt "Do another? (Y/N):"
}
#endregion Setup
Get-Mails
If ($Again -ieq "Y") {Get-Mails} ELSE {}
#>