Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

exchange 2010 powershell command issue

Posted on 2013-05-13
3
Medium Priority
?
423 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 1000 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 71

Accepted Solution

by:
Qlemo earned 1000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

In this post we will be converting StringData saved within a text file into a hash table. This can be further used in a PowerShell script for replacing settings that are dynamic in nature from environment to environment.
Want to know how to use Exchange Server Eseutil command? Go through this article as it gives you the know-how.
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…
In this video we show how to create an email address policy 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…

670 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