Hello Powershell Experts,
Powershell is one of those things that I don’t get to do all that often at work, so I just don’t have a great handle on the basics. What I’m trying to accomplish today is:
1. Get a list of users in a department
2. For each user in that list, I want to determine the mailbox size on our Exchange server
For the first goal, I can use the following command to get the list of users:
Get-qaduser –department sales | Select-object logonname
The command above produces a list that looks like the following:
LogonName
---------
emusta
sbrown
cflynn
psnider
mpalacios
jgrubb
jfergen
dkiewit
I would like the list to look like:
emusta
sbrown
cflynn
psnider
mpalacios
jgrubb
jfergen
dkiewit
I think I need to use an array to do this. My question is how do I add each logonname to a blank array? I know I set the blank array as:
$users = @()
To get the mailbox size for a single user, I would do the following:
get-mailboxstatistics emusta | Select-Object @{n="User";e={$_.DisplayName}}, @{n="Mailbox Size (MB)";e={$_.totalitemsize.value.ToMB()}}
How would I run through the array of users generated in step one to get the mailbox size for each one? Would it be something as simple as:
get-mailboxstatistics $Users | Select-Object @{n="User";e={$_.DisplayName}}, @{n="Mailbox Size (MB)";e={$_.totalitemsize.value.ToMB()}}
I’m sorry for asking such lame questions, but I’ve tried everything I can think of and any help would be appreciated.