PowerShell : GUI based Email Search and Removal in Exchange


Hello Readers,

Today I’ve made a small tool based on Windows Form to utilize the Exchange 2010 cmdlet Search-Mailbox  under the  hood.

PURPOSE : 

Search & Remove emails from mailbox(es) or make a copy of emails in order to review them . It could be utilized in scenarios such as :

  • Someone mistakenly sent an sensitive email to wrong recipients and now he wants it to be removed from the mailboxes of the recipients of those emails.
  • Unwanted emails (Malware, Spam, Virus) delivered to email addresses and you want to remove them, to avoid user machines getting infected of malicious content.
  • Email content auditing and review, without liaising with the mailbox owner. Since you can Copy emails from back end and no user intervention is required.

PREREQUISITES :

  1. Access to Exchange Management Shell (EMS).
  2. Administrative rights on Exchange 2010.
  3. Admin Mailbox where you can copy the emails.

GET THE SCRIPT : 

Click Here to go to my GitHub gist to get the code.

HOW TO RUN THE SCRIPT :

  1. Log onto the Exchange Mailbox Server where the script has been copied and open Exchange Management Shell.
  2. Browse to the directory path where the script is placed and hit Enter.
    1
  3. A windows form will popup, where in you are required to fill the details in order to search mailboxes.
    5
  1. Before filling the form, you should know what each of the above fields actually mean
    • Recipient Email : mention the email addresses of mailbox(es) separated by a semicolon ‘;’  .Like, in the above screenshot there are 2 email addresses to search for emails, so we have inserted a “;” in between them.
    • Sender Email : Internal or external email must have a sender information (sender Email address), that information will come here.
    • Search Keyword : All mailboxes will be searched for the emails with this matching Keyword. By default it will search all items Folders, Calendars, Attachments, Notes
    • Search only in Subject Line : If you check this check box only the emails that contains a matching keyword only in Subject Line will be identified. This sould be used to avoid unwanted keyword matches and to Pin point specific emails.
    • Start Date & End Date : This defines a date range in which emails will be searched. All dates would be Server local time from where script is ran.Let’s suppose you have to target an email that was received on 02/26/2016, so you’ll set the dates like-

      Start date = 02/25/2016  (A day before the original date)
      End date = 02/27/2016 (A day after the original date)

    • Delete Email : In case you want the Identified emails to be deleted from the target mailboxes mentioned in Recipient Email TextBox, you can check this box and those emails will be deleted.
      PLEASE NOTE :
      As a precaution, please run the script once without this checkbox checked, in order to make sure you’re deleting the exact emails not any unwanted emails. 
    • Admin email to keep a Copy : Mention the email address of the Admin mailbox where you want to copy the targeted emails.
  1. Once you’ve filled all required details, click on Search Button.
  1. Script execution will start and you’ll see a progress bar while the mailboxes are searched for the emails one by one.In case you’ve checked the Delete email Checkbox you’ll be prompted to confirm if you want to delete those emails, like in the below screenshot.

    2

  2. Once the script execution completes you’ll notice some information on the console that Search Succeeded or failed and where on the admin mailbox the emails had been copied. By default folder name will be “\Email Captures”3
  3. Now open the admin mailbox in outlook and you’ll find the target emails copied under “Email Captures folder” .4

Hope you find it useful, follow me on twitter @SinghPrateik for more interesting stuff 🙂

Advertisements

6 thoughts on “PowerShell : GUI based Email Search and Removal in Exchange

  1. Hi ,

    I am getting below error while Running the tool …any help on this would be appreciated ..

    [PS] C:\Script>.\Search-Mailbox.ps1
    New-Object : Cannot find type [“System.Windows.Forms.Form”]: make sure the assembly containing this type is loaded.
    At C:\Script\Search-Mailbox.ps1:7 char:23
    + $Form = New-Object <<<< “System.Windows.Forms.Form”;
    + CategoryInfo : InvalidType: (:) [New-Object], PSArgumentException
    + FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand

    Property 'Width' cannot be found on this object; make sure it exists and is settable.
    At C:\Script\Search-Mailbox.ps1:8 char:11
    + $Form. <<<< Width = 500;
    + CategoryInfo : InvalidOperation: (Width:String) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

    Property 'Height' cannot be found on this object; make sure it exists and is settable.
    At C:\Script\Search-Mailbox.ps1:9 char:11
    + $Form. <<<< Height = 400;
    + CategoryInfo : InvalidOperation: (Height:String) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

    Property 'Text' cannot be found on this object; make sure it exists and is settable.
    At C:\Script\Search-Mailbox.ps1:10 char:11
    + $Form. <<<< Text = 'Enter the required details'
    + CategoryInfo : InvalidOperation: (Text:String) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

    Property 'StartPosition' cannot be found on this object; make sure it exists and is settable.
    At C:\Script\Search-Mailbox.ps1:11 char:11
    + $Form. <<<< StartPosition = [System.Windows.Forms.FormStartPosition]::CenterScreen;
    + CategoryInfo : InvalidOperation: (StartPosition:String) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

    Property 'TopMost' cannot be found on this object; make sure it exists and is settable.
    At C:\Script\Search-Mailbox.ps1:12 char:11
    + $Form. <<<< TopMost = $true
    + CategoryInfo : InvalidOperation: (TopMost:String) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

    New-Object : Cannot find type [“System.Windows.Forms.Label”]: make sure the assembly containing this type is loaded
    .
    At C:\Script\Search-Mailbox.ps1:15 char:25
    + $Label1 = New-Object <<<< “System.Windows.Forms.Label”;
    + CategoryInfo : InvalidType: (:) [New-Object], PSArgumentException
    + FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand

    Property 'Left' cannot be found on this object; make sure it exists and is settable.
    At C:\Script\Search-Mailbox.ps1:16 char:13
    + $Label1. <<<< Left = 10;
    + CategoryInfo : InvalidOperation: (Left:String) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

    Property 'Top' cannot be found on this object; make sure it exists and is settable.
    At C:\Script\Search-Mailbox.ps1:17 char:13
    + $Label1. <<<< Top = 15;
    + CategoryInfo : InvalidOperation: (Top:String) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

    Property 'Text' cannot be found on this object; make sure it exists and is settable.
    At C:\Script\Search-Mailbox.ps1:18 char:13
    + $Label1. <<<< Text = 'Recipient Email';
    + CategoryInfo : InvalidOperation: (Text:String) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

    New-Object : Cannot find type [“System.Windows.Forms.Label”]: make sure the assembly containing this type is loaded
    .
    At C:\Script\Search-Mailbox.ps1:20 char:25
    + $Label2 = New-Object <<<< “System.Windows.Forms.Label”;
    + CategoryInfo : InvalidType: (:) [New-Object], PSArgumentException
    + FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand

    Property 'Left' cannot be found on this object; make sure it exists and is settable.
    At C:\Script\Search-Mailbox.ps1:21 char:13
    + $Label2. <<<< Left = 10;
    + CategoryInfo : InvalidOperation: (Left:String) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

    Property 'Top' cannot be found on this object; make sure it exists and is settable.
    At C:\Script\Search-Mailbox.ps1:22 char:13
    + $Label2. <<<< Top = 40;
    + CategoryInfo : InvalidOperation: (Top:String) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

    Property 'Text' cannot be found on this object; make sure it exists and is settable.
    At C:\Script\Search-Mailbox.ps1:23 char:13
    + $Label2. <<<< Text = 'Sender Email';
    + CategoryInfo : InvalidOperation: (Text:String) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

    New-Object : Cannot find type [“System.Windows.Forms.Label”]: make sure the assembly containing this type is loaded
    .
    At C:\Script\Search-Mailbox.ps1:25 char:25
    + $Label3 = New-Object <<<< “System.Windows.Forms.Label”;
    + CategoryInfo : InvalidType: (:) [New-Object], PSArgumentException
    + FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand

    Property 'Left' cannot be found on this object; make sure it exists and is settable.
    At C:\Script\Search-Mailbox.ps1:26 char:13
    + $Label3. <<<< Left = 10;
    + CategoryInfo : InvalidOperation: (Left:String) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

    Property 'Top' cannot be found on this object; make sure it exists and is settable.
    At C:\Script\Search-Mailbox.ps1:27 char:13
    + $Label3. <<<< Top = 65;
    + CategoryInfo : InvalidOperation: (Top:String) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

    Property 'Width' cannot be found on this object; make sure it exists and is settable.
    At C:\Script\Search-Mailbox.ps1:28 char:13
    + $Label3. <<<< Width = 180
    + CategoryInfo : InvalidOperation: (Width:String) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

    Property 'Text' cannot be found on this object; make sure it exists and is settable.
    At C:\Script\Search-Mailbox.ps1:29 char:13
    + $Label3. <<<< Text = 'Search Keyword';
    + CategoryInfo : InvalidOperation: (Text:String) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

    New-Object : Cannot find type [“System.Windows.Forms.Label”]: make sure the assembly containing this type is loaded
    .
    At C:\Script\Search-Mailbox.ps1:32 char:25
    + $Label4 = New-Object <<<< “System.Windows.Forms.Label”;
    + CategoryInfo : InvalidType: (:) [New-Object], PSArgumentException
    + FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand

    Property 'Left' cannot be found on this object; make sure it exists and is settable.
    At C:\Script\Search-Mailbox.ps1:33 char:13
    + $Label4. <<<< Left = 10;
    + CategoryInfo : InvalidOperation: (Left:String) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

    Property 'Top' cannot be found on this object; make sure it exists and is settable.
    At C:\Script\Search-Mailbox.ps1:34 char:13
    + $Label4. <<<< Top = 115;
    + CategoryInfo : InvalidOperation: (Top:String) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

    Property 'Width' cannot be found on this object; make sure it exists and is settable.
    At C:\Script\Search-Mailbox.ps1:35 char:13
    + $Label4. <<<< Width = 180
    + CategoryInfo : InvalidOperation: (Width:String) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

    Property 'Text' cannot be found on this object; make sure it exists and is settable.
    At C:\Script\Search-Mailbox.ps1:36 char:13
    + $Label4. <<<< Text = 'Start Date [MM/DD/YYYY]';
    + CategoryInfo : InvalidOperation: (Text:String) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

    New-Object : Cannot find type [“System.Windows.Forms.Label”]: make sure the assembly containing this type is loaded
    .
    At C:\Script\Search-Mailbox.ps1:39 char:25
    + $Label5 = New-Object <<<< “System.Windows.Forms.Label”;
    + CategoryInfo : InvalidType: (:) [New-Object], PSArgumentException
    + FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand

    Property 'Left' cannot be found on this object; make sure it exists and is settable.
    At C:\Script\Search-Mailbox.ps1:40 char:13
    + $Label5. <<<< Left = 10;
    + CategoryInfo : InvalidOperation: (Left:String) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

    Property 'Top' cannot be found on this object; make sure it exists and is settable.
    At C:\Script\Search-Mailbox.ps1:41 char:13
    + $Label5. <<<< Top = 140;
    + CategoryInfo : InvalidOperation: (Top:String) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

    Property 'Width' cannot be found on this object; make sure it exists and is settable.
    At C:\Script\Search-Mailbox.ps1:42 char:13
    + $Label5. <<<< Width = 180
    + CategoryInfo : InvalidOperation: (Width:String) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

    Property 'Text' cannot be found on this object; make sure it exists and is settable.
    At C:\Script\Search-Mailbox.ps1:43 char:13
    + $Label5. <<<< Text = 'End Date [MM/DD/YYYY]';
    + CategoryInfo : InvalidOperation: (Text:String) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

    New-Object : Cannot find type [“System.Windows.Forms.Label”]: make sure the assembly containing this type is loaded
    .
    At C:\Script\Search-Mailbox.ps1:45 char:25
    + $Label6 = New-Object <<<< “System.Windows.Forms.Label”;
    + CategoryInfo : InvalidType: (:) [New-Object], PSArgumentException
    + FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand

    Property 'Left' cannot be found on this object; make sure it exists and is settable.
    At C:\Script\Search-Mailbox.ps1:46 char:13
    + $Label6. <<<< Left = 10;
    + CategoryInfo : InvalidOperation: (Left:String) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

    Property 'Top' cannot be found on this object; make sure it exists and is settable.
    At C:\Script\Search-Mailbox.ps1:47 char:13
    + $Label6. <<<< Top = 165;
    + CategoryInfo : InvalidOperation: (Top:String) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

    Property 'Width' cannot be found on this object; make sure it exists and is settable.
    At C:\Script\Search-Mailbox.ps1:48 char:13
    + $Label6. <<<< Width = 180
    + CategoryInfo : InvalidOperation: (Width:String) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

    Property 'Text' cannot be found on this object; make sure it exists and is settable.
    At C:\Script\Search-Mailbox.ps1:49 char:13
    + $Label6. <<<< Text = 'Delete Email';
    + CategoryInfo : InvalidOperation: (Text:String) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

    New-Object : Cannot find type [“System.Windows.Forms.Label”]: make sure the assembly containing this type is loaded
    .
    At C:\Script\Search-Mailbox.ps1:53 char:25
    + $Label7 = New-Object <<<< “System.Windows.Forms.Label”;
    + CategoryInfo : InvalidType: (:) [New-Object], PSArgumentException
    + FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand

    Property 'Left' cannot be found on this object; make sure it exists and is settable.
    At C:\Script\Search-Mailbox.ps1:54 char:13
    + $Label7. <<<< Left = 10;
    + CategoryInfo : InvalidOperation: (Left:String) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

    Property 'Top' cannot be found on this object; make sure it exists and is settable.
    At C:\Script\Search-Mailbox.ps1:55 char:13
    + $Label7. <<<< Top = 190;
    + CategoryInfo : InvalidOperation: (Top:String) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

    Property 'Width' cannot be found on this object; make sure it exists and is settable.
    At C:\Script\Search-Mailbox.ps1:56 char:13
    + $Label7. <<<< Width = 180
    + CategoryInfo : InvalidOperation: (Width:String) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

    Property 'Text' cannot be found on this object; make sure it exists and is settable.
    At C:\Script\Search-Mailbox.ps1:57 char:13
    + $Label7. <<<< Text = 'Admin Email to keep a copy';
    + CategoryInfo : InvalidOperation: (Text:String) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

    New-Object : Cannot find type [“System.Windows.Forms.Label”]: make sure the assembly containing this type is loaded
    .
    At C:\Script\Search-Mailbox.ps1:61 char:25
    + $Label8 = New-Object <<<< “System.Windows.Forms.Label”;
    + CategoryInfo : InvalidType: (:) [New-Object], PSArgumentException
    + FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand

    Property 'Left' cannot be found on this object; make sure it exists and is settable.
    At C:\Script\Search-Mailbox.ps1:62 char:13
    + $Label8. <<<< Left = 10;
    + CategoryInfo : InvalidOperation: (Left:String) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

    Property 'Top' cannot be found on this object; make sure it exists and is settable.
    At C:\Script\Search-Mailbox.ps1:63 char:13
    + $Label8. <<<< Top = 90;
    + CategoryInfo : InvalidOperation: (Top:String) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

    Property 'Width' cannot be found on this object; make sure it exists and is settable.
    At C:\Script\Search-Mailbox.ps1:64 char:13
    + $Label8. <<<< Width = 180
    + CategoryInfo : InvalidOperation: (Width:String) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

    Property 'Text' cannot be found on this object; make sure it exists and is settable.
    At C:\Script\Search-Mailbox.ps1:65 char:13
    + $Label8. <<<< Text = 'Search Only in Subject line';
    + CategoryInfo : InvalidOperation: (Text:String) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

    New-Object : Cannot find type [“System.Windows.Forms.TextBox”]: make sure the assembly containing this type is load
    ed.
    At C:\Script\Search-Mailbox.ps1:68 char:27
    + $TextBox1 = New-Object <<<< “System.Windows.Forms.TextBox”;
    + CategoryInfo : InvalidType: (:) [New-Object], PSArgumentException
    + FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand

    Property 'Left' cannot be found on this object; make sure it exists and is settable.
    At C:\Script\Search-Mailbox.ps1:69 char:15
    + $TextBox1. <<<< Left = 200;
    + CategoryInfo : InvalidOperation: (Left:String) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

    Property 'Top' cannot be found on this object; make sure it exists and is settable.
    At C:\Script\Search-Mailbox.ps1:70 char:15
    + $TextBox1. <<<< Top = 15;
    + CategoryInfo : InvalidOperation: (Top:String) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

    Property 'width' cannot be found on this object; make sure it exists and is settable.
    At C:\Script\Search-Mailbox.ps1:71 char:15
    + $TextBox1. <<<< width = 250;
    + CategoryInfo : InvalidOperation: (width:String) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

    New-Object : Cannot find type [“System.Windows.Forms.TextBox”]: make sure the assembly containing this type is load
    ed.
    At C:\Script\Search-Mailbox.ps1:73 char:27
    + $TextBox2 = New-Object <<<< “System.Windows.Forms.TextBox”;
    + CategoryInfo : InvalidType: (:) [New-Object], PSArgumentException
    + FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand

    Property 'Left' cannot be found on this object; make sure it exists and is settable.
    At C:\Script\Search-Mailbox.ps1:74 char:15
    + $TextBox2. <<<< Left = 200;
    + CategoryInfo : InvalidOperation: (Left:String) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

    Property 'Top' cannot be found on this object; make sure it exists and is settable.
    At C:\Script\Search-Mailbox.ps1:75 char:15
    + $TextBox2. <<<< Top = 40;
    + CategoryInfo : InvalidOperation: (Top:String) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

    Property 'width' cannot be found on this object; make sure it exists and is settable.
    At C:\Script\Search-Mailbox.ps1:76 char:15
    + $TextBox2. <<<< width = 250;
    + CategoryInfo : InvalidOperation: (width:String) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

    New-Object : Cannot find type [“System.Windows.Forms.TextBox”]: make sure the assembly containing this type is load
    ed.
    At C:\Script\Search-Mailbox.ps1:79 char:27
    + $TextBox3 = New-Object <<<< “System.Windows.Forms.TextBox”;
    + CategoryInfo : InvalidType: (:) [New-Object], PSArgumentException
    + FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand

    Property 'Left' cannot be found on this object; make sure it exists and is settable.
    At C:\Script\Search-Mailbox.ps1:80 char:15
    + $TextBox3. <<<< Left = 200;
    + CategoryInfo : InvalidOperation: (Left:String) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

    Property 'Top' cannot be found on this object; make sure it exists and is settable.
    At C:\Script\Search-Mailbox.ps1:81 char:15
    + $TextBox3. <<<< Top = 65;
    + CategoryInfo : InvalidOperation: (Top:String) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

    Property 'width' cannot be found on this object; make sure it exists and is settable.
    At C:\Script\Search-Mailbox.ps1:82 char:15
    + $TextBox3. <<<< width = 250;
    + CategoryInfo : InvalidOperation: (width:String) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

    New-Object : Cannot find type [“System.Windows.Forms.TextBox”]: make sure the assembly containing this type is load
    ed.
    At C:\Script\Search-Mailbox.ps1:85 char:27
    + $TextBox4 = New-Object <<<< “System.Windows.Forms.TextBox”;
    + CategoryInfo : InvalidType: (:) [New-Object], PSArgumentException
    + FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand

    Property 'Left' cannot be found on this object; make sure it exists and is settable.
    At C:\Script\Search-Mailbox.ps1:86 char:15
    + $TextBox4. <<<< Left = 200;
    + CategoryInfo : InvalidOperation: (Left:String) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

    Property 'Top' cannot be found on this object; make sure it exists and is settable.
    At C:\Script\Search-Mailbox.ps1:87 char:15
    + $TextBox4. <<<< Top = 115;
    + CategoryInfo : InvalidOperation: (Top:String) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

    Property 'width' cannot be found on this object; make sure it exists and is settable.
    At C:\Script\Search-Mailbox.ps1:88 char:15
    + $TextBox4. <<<< width = 250;
    + CategoryInfo : InvalidOperation: (width:String) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

    New-Object : Cannot find type [“System.Windows.Forms.TextBox”]: make sure the assembly containing this type is load
    ed.
    At C:\Script\Search-Mailbox.ps1:91 char:27
    + $TextBox5 = New-Object <<<< “System.Windows.Forms.TextBox”;
    + CategoryInfo : InvalidType: (:) [New-Object], PSArgumentException
    + FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand

    Property 'Left' cannot be found on this object; make sure it exists and is settable.
    At C:\Script\Search-Mailbox.ps1:92 char:15
    + $TextBox5. <<<< Left = 200;
    + CategoryInfo : InvalidOperation: (Left:String) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

    Property 'Top' cannot be found on this object; make sure it exists and is settable.
    At C:\Script\Search-Mailbox.ps1:93 char:15
    + $TextBox5. <<<< Top = 140;
    + CategoryInfo : InvalidOperation: (Top:String) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

    Property 'width' cannot be found on this object; make sure it exists and is settable.
    At C:\Script\Search-Mailbox.ps1:94 char:15
    + $TextBox5. <<<< width = 250;
    + CategoryInfo : InvalidOperation: (width:String) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

    New-Object : Cannot find type [“System.Windows.Forms.TextBox”]: make sure the assembly containing this type is load
    ed.
    At C:\Script\Search-Mailbox.ps1:106 char:27
    + $TextBox6 = New-Object <<<< “System.Windows.Forms.TextBox”;
    + CategoryInfo : InvalidType: (:) [New-Object], PSArgumentException
    + FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand

    Property 'Left' cannot be found on this object; make sure it exists and is settable.
    At C:\Script\Search-Mailbox.ps1:107 char:15
    + $TextBox6. <<<< Left = 200;
    + CategoryInfo : InvalidOperation: (Left:String) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

    Property 'Top' cannot be found on this object; make sure it exists and is settable.
    At C:\Script\Search-Mailbox.ps1:108 char:15
    + $TextBox6. <<<< Top = 190;
    + CategoryInfo : InvalidOperation: (Top:String) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

    Property 'width' cannot be found on this object; make sure it exists and is settable.
    At C:\Script\Search-Mailbox.ps1:109 char:15
    + $TextBox6. <<<< width = 250;
    + CategoryInfo : InvalidOperation: (width:String) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

    New-Object : Cannot find type [“System.Windows.Forms.Button”]: make sure the assembly containing this type is loade
    d.
    At C:\Script\Search-Mailbox.ps1:112 char:27
    + $OKbutton = New-Object <<<< “System.Windows.Forms.Button”;
    + CategoryInfo : InvalidType: (:) [New-Object], PSArgumentException
    + FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand

    Property 'Left' cannot be found on this object; make sure it exists and is settable.
    At C:\Script\Search-Mailbox.ps1:113 char:15
    + $OKbutton. <<<< Left = 10;
    + CategoryInfo : InvalidOperation: (Left:String) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

    Property 'Top' cannot be found on this object; make sure it exists and is settable.
    At C:\Script\Search-Mailbox.ps1:114 char:15
    + $OKbutton. <<<< Top = 220;
    + CategoryInfo : InvalidOperation: (Top:String) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

    Property 'Width' cannot be found on this object; make sure it exists and is settable.
    At C:\Script\Search-Mailbox.ps1:115 char:15
    + $OKbutton. <<<< Width = 100;
    + CategoryInfo : InvalidOperation: (Width:String) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

    The term '“SEARCH”' is not recognized as the name of a cmdlet, function, script file, or operable program. Check th
    e spelling of the name, or if a path was included, verify that the path is correct and try again.
    At C:\Script\Search-Mailbox.ps1:116 char:34
    + $OKbutton.Text = “SEARCH” <<<< ;
    + CategoryInfo : ObjectNotFound: (“SEARCH”:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

    You cannot call a method on a null-valued expression.
    At C:\Script\Search-Mailbox.ps1:124 char:24
    + $OKbutton.Add_Click <<<< ($eventHandler) ;
    + CategoryInfo : InvalidOperation: (Add_Click:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

    You cannot call a method on a null-valued expression.
    At C:\Script\Search-Mailbox.ps1:126 char:23
    + $Form.Controls.Add <<<< ($OKbutton);
    + CategoryInfo : InvalidOperation: (Add:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

    You cannot call a method on a null-valued expression.
    At C:\Script\Search-Mailbox.ps1:127 char:23
    + $Form.Controls.Add <<<< ($Label1);
    + CategoryInfo : InvalidOperation: (Add:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

    You cannot call a method on a null-valued expression.
    At C:\Script\Search-Mailbox.ps1:128 char:23
    + $Form.Controls.Add <<<< ($Label2);
    + CategoryInfo : InvalidOperation: (Add:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

    You cannot call a method on a null-valued expression.
    At C:\Script\Search-Mailbox.ps1:129 char:23
    + $Form.Controls.Add <<<< ($Label3);
    + CategoryInfo : InvalidOperation: (Add:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

    You cannot call a method on a null-valued expression.
    At C:\Script\Search-Mailbox.ps1:130 char:23
    + $Form.Controls.Add <<<< ($Label4);
    + CategoryInfo : InvalidOperation: (Add:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

    You cannot call a method on a null-valued expression.
    At C:\Script\Search-Mailbox.ps1:131 char:23
    + $Form.Controls.Add <<<< ($Label5);
    + CategoryInfo : InvalidOperation: (Add:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

    You cannot call a method on a null-valued expression.
    At C:\Script\Search-Mailbox.ps1:132 char:23
    + $Form.Controls.Add <<<< ($Label6);
    + CategoryInfo : InvalidOperation: (Add:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

    You cannot call a method on a null-valued expression.
    At C:\Script\Search-Mailbox.ps1:133 char:23
    + $Form.Controls.Add <<<< ($Label7);
    + CategoryInfo : InvalidOperation: (Add:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

    You cannot call a method on a null-valued expression.
    At C:\Script\Search-Mailbox.ps1:134 char:23
    + $Form.Controls.Add <<<< ($Label8);
    + CategoryInfo : InvalidOperation: (Add:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

    You cannot call a method on a null-valued expression.
    At C:\Script\Search-Mailbox.ps1:135 char:23
    + $Form.Controls.Add <<<< ($CheckBox2);
    + CategoryInfo : InvalidOperation: (Add:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

    You cannot call a method on a null-valued expression.
    At C:\Script\Search-Mailbox.ps1:136 char:23
    + $Form.Controls.Add <<<< ($TextBox1);
    + CategoryInfo : InvalidOperation: (Add:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

    You cannot call a method on a null-valued expression.
    At C:\Script\Search-Mailbox.ps1:137 char:23
    + $Form.Controls.Add <<<< ($TextBox2);
    + CategoryInfo : InvalidOperation: (Add:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

    You cannot call a method on a null-valued expression.
    At C:\Script\Search-Mailbox.ps1:138 char:23
    + $Form.Controls.Add <<<< ($TextBox3);
    + CategoryInfo : InvalidOperation: (Add:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

    You cannot call a method on a null-valued expression.
    At C:\Script\Search-Mailbox.ps1:139 char:23
    + $Form.Controls.Add <<<< ($TextBox4);
    + CategoryInfo : InvalidOperation: (Add:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

    You cannot call a method on a null-valued expression.
    At C:\Script\Search-Mailbox.ps1:140 char:23
    + $Form.Controls.Add <<<< ($TextBox5);
    + CategoryInfo : InvalidOperation: (Add:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

    You cannot call a method on a null-valued expression.
    At C:\Script\Search-Mailbox.ps1:141 char:23
    + $Form.Controls.Add <<<< ($CheckBox);
    + CategoryInfo : InvalidOperation: (Add:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

    You cannot call a method on a null-valued expression.
    At C:\Script\Search-Mailbox.ps1:142 char:23
    + $Form.Controls.Add <<<< ($TextBox6);
    + CategoryInfo : InvalidOperation: (Add:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

    You cannot call a method on a null-valued expression.
    At C:\Script\Search-Mailbox.ps1:143 char:21
    + $Form.ShowDialog <<<< ()|Out-Null
    + CategoryInfo : InvalidOperation: (ShowDialog:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

    You cannot call a method on a null-valued expression.
    At C:\Script\Search-Mailbox.ps1:165 char:42
    + Foreach($Target in $TargetEmail.Split <<<

    Thank you !

    Like

  2. what changes would need to be made to this for it to work with 2013? the reason i ask is because I ran this against my exchange 2013 server and kept getting the below error

    The property keyword isn’t supported.
    + CategoryInfo : InvalidArgument: (:) [], ParserException
    + FullyQualifiedErrorId : [Server=********,RequestId=4989a638-50d9-4815-ad1e-6267b0bd0002,TimeStamp=12/5/2016 10
    :16:47 PM] [FailureCategory=Cmdlet-ParserException] AF3EA881
    + PSComputerName : ***.*****.com

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s