Quantcast
Channel: Exchange Server 2010 forum
Viewing all articles
Browse latest Browse all 8820

what can I do to fill a variable with multiple value using foreach loop

$
0
0

I need to fill the variable $navmailbox with all mailboxes that belongs to nav company but I can’t do that with the below script as $navmailbox only take the last value. The $navmailbo does not add a new  value to the old value in other words , if $navusers=peter,lydia $navmailbox will only contains the last mailbox of lydia not peter and lydia 

what can I do to fill a variable with multiple value using foreach loop

 

$navusers=get-user | ? {$_.Company -eq "navt"} foreach($mailbox in $navusers) {$navmailbox=get-mailbox -id $mailbox.name}

if $navusers=peter,lydia $navmailbox will only contains the last mailbox of lydia not peter and lydia 

 

why I need that because I want a script that ouput the quota of nav company mailboxes with their database limit

 I made a simple script to get the quota of some users in a specific company

$navusers=get-user | ? {$_.Company -eq "navt"} foreach($mailbox in $navusers) {get-mailbox -id $mailbox.name | select name,ProhibitSendQuota,ProhibitSendReceiveQuota,database}

this work fine but I want to know the database limits ,so I need the get-mailboxdatabase command so I edited the script to be like that but the field "DBwarninquota"is displayed without values as shown below

 

$navusers=get-user | ? {$_.Company -eq "nav"} foreach($mailbox in $navusers) {get-mailbox -id $mailbox.name | select name,ProhibitSendQuota,

ProhibitSendReceiveQuota,@{n="DBwarninquota";e={(get-maiboxdatabase -id $_.database).ProhibitSendQuota}}}

Name

ProhibitSendQuota

ProhibitSendReceiveQuota

Database

ProhibitSendQuota

----

-----------------

------------------------

--------

 

 

adel

unlimited

unlimited

NAV

 

 

mohamed

unlimited

unlimited

NAV

 

 

eman

unlimited

unlimited

NAV

 

 

hamdy

unlimited

unlimited

NAV

 

 

haitham

4.883 GB

unlimited

NAV

 

 

mamdouh

unlimited

unlimited

NAV

 

 

medhat

unlimited

unlimited

NAV

 

 

mohamed

unlimited

unlimited

NAV

 

 

mohamed_

unlimited

unlimited

NAV

 

 

mohamed_ta

unlimited

unlimited

NAV

 

 

ms_

unlimited

unlimited

NAV

 

 

 

I think this is because the variable $mailbox.name doesn't contain the properties of mailbox it contains the properties of users

I think that I should have a variable that contains the mailboxes of navusers, I can't fill a variable with all the mailboxees using this command

 


Viewing all articles
Browse latest Browse all 8820

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>