Solved

exchange 2010 powershell command issue

Posted on 2013-05-13
3
383 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
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 68

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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Following basic email etiquette rules will help you write a professional email and achieve a good, lasting impression with your contacts.
This article lists the top 5 free OST to PST Converter Tools. These tools save a lot of time for users when they want to convert OST to PST after their exchange server is no longer available or some other critical issue with exchange server or impor…
In this video we show how to create a Shared Mailbox 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 Recipients >> Sha…
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…

932 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now