Solved

exchange 2010 powershell command issue

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

Too many email signature changes to deal with?

Are you constantly being asked to update your organization's email signatures? Do they take up too much of your time? Wouldn't you love to be able to manage all signatures from one central location, easily design them and deploy them quickly to users. Well, you can!

Join & Write a Comment

ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
Scam emails are a huge burden for many businesses. Spotting one is not always easy. Follow our tips to identify if an email you receive is a scam.
In this video we show how to create a Distribution Group 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 >>…
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…

708 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

13 Experts available now in Live!

Get 1:1 Help Now