Solved

exchange 2010 powershell command issue

Posted on 2013-05-13
3
413 Views
Last Modified: 2013-05-13
Need some help with a powershell command. I'm kinda new with using powershell.

How can i append something to a current variable. Is it even possible.  For example the command below

$mailbox = get-mailbox 'testuser'

now $mailbox holds the value for testuser,

how can i add other users into the variable also. For example I wanted to add testuser10 to the variable.  

So when i run $mailbox i'll get the info for both user.  My point for doing this is so i can run a command to delete some emails for a few users. The command i want to be able to run when i have all my users in the variables is below.

$mailbox| Search-Mailbox -SearchQuery 'Subject:"this is a test"' -DeleteContent

thanks in advance.
0
Comment
Question by:sirichaiphumirat
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 40

Assisted Solution

by:Subsun
Subsun earned 250 total points
ID: 39162136
Try to set the var as a array..
$mailbox = @()
$mailbox += get-mailbox 'testuser'
$mailbox += get-mailbox 'testuser10'

Open in new window

And if you have a list of users in txt file.. Try..
$mailbox = GC c:\users.txt | Get-mailbox

Open in new window

0
 
LVL 70

Accepted Solution

by:
Qlemo earned 250 total points
ID: 39162374
Other ways to get an array is
$mailbox += , (get-mailbox 'testuser')
$mailbox += , (get-mailbox 'testuser10')

Open in new window

or
$mailbox = 'testuser', 'testuser10' | get-mailbox

Open in new window

or
$mailbox = , (get-mailbox 'testuser'), (get-mailbox 'testuser10')

Open in new window

(and many more).
0
 

Author Comment

by:sirichaiphumirat
ID: 39162471
great thank you.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A list of top three free exchange EDB viewers that helps the user to extract a mailbox from an unmounted .edb file and get a clear preview of all emails & other items with just a single click on mailboxes.
My attempt to use PowerShell and other great resources found online to simplify the deployment of Office 365 ProPlus client components to any workstation that needs it, regardless of existing Office components that may be needing attention.
In this video we show how to create an Accepted Domain in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Mail Flow >> Ac…
The basic steps you have just learned will be implemented in this video. The basic steps are shown to configure an Exchange DAG in a live working Exchange Server Environment and manage the same (Exchange Server 2010 Software is used in a Windows Ser…

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question