Solved

exchange 2010 powershell command issue

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

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Learn to move / copy / export exchange contacts to iPhone without using any software. Also see the issues in configuration of exchange with iPhone to migrate contacts.
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 mailbox database 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 Servers >> Data…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

810 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