Solved

arrays powershll

Posted on 2012-04-05
3
411 Views
Last Modified: 2012-08-14
I have a script here that I am trying to get to run. It basically goes into the text file and pulls each alias out and runs this against the email alias. The first problem is where to place the alias in the script and the second question is I tried to hard code this in under the command and it still failes.

$userList = Get-Content ("c:\list.txt file")

$MasterArray = @()

foreach ($user in $userList)
      {
      $TempArray = @()
      $TempArray = "" | Select Name, Foldersize, itemsinfolder, prohibitsendquota, UseDatabaseQuotaDefaults
      
      $folderstats = get-mailboxfolderstatistics -id "alias" | Select Name, Foldersize, itemsinfolder
      $MAILQUOTA = get-mailbox -id "alias" | select prohibitsendquota, usedatabasedefaults

      $TempArray.Name = $folderstats.Name
      $TempArray.Foldersize = $folderstats.Name
      $TempArray.itemsinfolder = $folderstats.itemsinfolder      
      $TempArray.prohibitsendquota = $MAILQUOTA.prohibitsendquota
      $TempArray.UseDatabaseQuotaDefaults = $$MAILQUOTA.UseDatabaseQuotaDefaults
      
      $MasterArray += $TempArray
      }

$MasterArray | ft
0
Comment
Question by:techdrive
[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
  • 2
3 Comments
 
LVL 5

Expert Comment

by:kollenh
ID: 37813013
There are multiple things going wrong for you.  You're returning the results of 'get-mailboxfolderstatistics' to a value but it's actually a table that you're returning; $folderstats.Name is an array, not a single value.  You'd need to loop through the items.

Can we step back and have you explain exactly what you're trying to accomplish?  I suspect you want to create a report of mailbox values for a list of users, yes?
0
 

Author Comment

by:techdrive
ID: 37813098
Here is what I am trying to accomplish. I am trying to run two different commands and then pull the results together. I thought an array would accomplish the task. The below commands satisfies what I am looking for but would like for a way to stick the alias in there and have these 5 fields to display.



get-mailbox -id "alias" | select prohibitsendquota, usedatabasedefaults


get-mailboxfolderstatistics -id "alias" | Select Name, Foldersize, itemsinfolder
0
 
LVL 5

Accepted Solution

by:
kollenh earned 500 total points
ID: 37813370
I understand now; you're basically wanting to join two separate tables.  This should get you on the right track, if it isn't exactly what you want:
Get-Content c:\userlist.txt | foreach {
	$master = @()
	$quota = get-mailbox -id $_ | select ProhibitSendQuota,UseDatabaseQuotaDefaults	
	get-mailboxfolderstatistics -id $_ | select Name,FolderSize,ItemsInFolder | % {
		$temp = @()
		$temp = "" | select Name,FolderSize,ItemsInFolder,ProhibitSendQuota,UseDatabaseQuotaDefaults
		$temp.name = $_.Name
		$temp.FolderSize = $_.FolderSize
		$temp.ItemsInFolder = $_.ItemsInFolder
		$temp.ProhibitSendQuota = $quota.ProhibitSendQuota
		$temp.UseDatabaseQuotaDefaults = $quota.UseDatabaseQuotaDefaults
		$master = $master + $temp
	}
	$master | ft -a
}

Open in new window

0

Featured Post

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
My attempt to use PowerShell and other great resources found online to simplify the deployment of Office 365 ProPlus client components to any workstation that needs it, regardless of existing Office components that may be needing attention.
In this video we show how to create a Contact 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 >> Contact ta…
To show how to create a transport rule 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 >> Rules tab.:  To cr…

734 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