I am fairly new to Powershell and need help with a syntax issue. I have a script that I use to process employee terminations. It works well but I am trying add a new piece to it. When the script finishes I need to be able to take the results of the get-mailboxexportrequest -status completed and disable the successfully completed archive.
In order to do that I have to be able to use the returned ‘Mailbox’ identity property as this is what get-mailboxexportrequest returns and compare it back to the original list of items to get the correct alias or email address to use in the disable mailbox cmdlet.
Here is where I am getting stuck. I import a csv file with the following information email address, sip address and sAMAccountName into the variable $mailboxes. I need to be able to take the sAMAccountName from $Mailboxes and use it to get the Mailbox identity for each item in the list into a new variable. I will then be able to use a foreach loop and compare back in a ‘Where’ clause to get the correct identity parameter to use with the disable cmdlet.
I have tried the following:
$mailboxobject = get-mailbox $mailboxes.samaccountname | select-object -property identity (this gives me an error about converting the System.Collections.ArrayList
I also tried a foreach but that just looped and looped and looped with the Warning about only the first 1000 items being returned
I am sure I am missing something important here, but am not quite sure what