Powershell Query

Status
Not open for further replies.
J

Jacko1234



Hi

I am querying using the following cmdlets

gt--mailboxdatabase | get-CASMailbox

I need to get some properties from the 1st cmdlet and some from the 2nd cmdlet, is that possible, can i get some example code?

Regards
 
B

Brian Day MCITP

Yes, more detail about what you want to do is necessary.
 
J

Jacko1234



In Exchange Management Console select mailbox node (the 3rd container) , select a Mailuser and right click to display properties there are table like "General",,"User Information", "Address and Phone, "Organization"", Mailbox Features", "Account" etc, i need to get all the data from all tabs for all users with a single line cmdlet(s)
 
G

Gavin-Zhang

Hi Jack,
Per your description, I think it cannot be achieved by EMS, because some attributes of the user is conifigured in AD, such as "member of" and so on.
But you could use get-user and get-mailbox to get some of the attributes.
Others you could use ad script to achieve it.
Regards!
Gavin
 
J

Jacko1234



Hi Gavin,

I am aware that not all properties can be retrieved using EMS, i have already achieved part of the results using and AD and EMS.

My original question still remains

How do i get some properties from 2 comdlets

eg get-User | get-CASMailbox

I need some properties of get-user and some of get-CASMailbox with possibly a single command presently i use Get-User the loop through and get the CASMailbox for each user which is time consuming process

Hope i have made myself clear

Regards

Jack
 
J

Jacko1234



does anyone know how to use these Namespaces

Microsoft.Exchange.Data

Microsoft.Exchange.Data.Direcvtory

Microsoft.Exchange.Data.Management

These can help in retrieving data from the outdated System.Directory.Services Namespace which return a value of type comObject at times, which is difficult to convert to string

There is very little documentation on these Namespace on the Microsoft site.
 
S

Steve Goodman

My original question still remains

How do i get some properties from 2 comdlets

eg get-User | get-CASMailbox


Hi Jack,

You can use the "select-object" cmdlet to do this. For example:

$o=Get-User; $o | Select-Object SamAccountName, FirstName, LastName, @{Name="IMAPEnabled"; Expression= {(Get-CasMailbox -Identity $_.Identity).IMAPEnabled}}, @{Name="TotalItemSize"; Expression={(Get-MailboxStatistics -Identity $_.Identity).TotalItemSize}}

What the above does is stores the result of Get-User into the object "$o", to avoid pipelining issues, then $o is piped into Select-Object. We can select Get-User's properties, such as SamAccountName, FirstName and LastName, and then use Select-Object to calculate extra properties by making expressions. The expression can be the result of any powershell command, and can use the $_. notation to pull properties from the input object. These calculated values are basically @{Name="Display name of property"; Expression={Powershell Command} }

Steve


Steve Goodman
Check out my Blog for more Exchange info or find me on Twitter
 
M

mjolinor



Another method is to start with an array of obejects with selected properties, and then add the additional properties you want explicitly as noteproperties:

$users = Get-User | Select-Object SamAccountName, FirstName, LastName

foreach ($users in $users){

$_ | add-member -membertype noteproperty -name ""IMAPEnabled" -value (Get-CasMailbox -Identity $_.SamAccountName).IMAPEnabled

$_ | add-membery -membertype noteproperty -name"TotalItemSize" -value (Get-MailboxStatistics -Identity $_.SamAccountName).TotalItemSize

}

$users

[string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
 
Status
Not open for further replies.
Thread starter Similar threads Forum Replies Date
Diane Poremsky Use PowerShell to log into Office 365 Exchange New Slipstick.com Articles 0
marcadamcarter Interrogate Outlook GAL with PowerShell Using Outlook 0
R Exchange - Locating a user that has log files but is not found using powershell Exchange Server Administration 1
Britonius Exchange Powershell to Remove Reviewer access from all Folders in a mailbox? Using Outlook 3
P Could the powershell Version be wrong? Exchange Server Administration 1
I Exchange 2010 Powershell Exchange Server Administration 1
T Problems opening the EMS and EMC - WinRM, Kerberos, Powershell Exchange Server Administration 4
P Error when trying to open EMC and Powershell Exchange Server Administration 4
B Create Exchange PowerShell Virtual Directpory Exchange Server Administration 3
à owa and powershell take times on exchange 2010 Exchange Server Administration 8
M PowerShell Get-Mailbox truncates fields in the results Exchange Server Administration 3
S EMC, EMS & Powershell issues. Cannot manage Exchange 2010 after install Exchange Server Administration 4
G Moving messages within mailbox via PowerShell Exchange Server Administration 1
N Failed Exchange 2010 SP1 Installation PowerShell "unauthorized operation" Exchange Server Administration 2
T You must Provide a value for this property on powershell cmdlet Exchange Server Administration 3
C ClamAgent free antivirus for exchange help with JS in Powershell 2.0 Exchange Server Administration 1
S Determine Managed Folder Policy for Mailbox in Powershell Exchange 2010 SP1 Exchange Server Administration 4
W PowerShell Help in Exchange 2010 Exchange Server Administration 14
S Applying Managed Folder Policy using Powershell Exchange Server Administration 2
F Powershell help required Exchange Server Administration 4
R Exchange Powershell getting the forward email address for mailboxes Exchange Server Administration 2
I Can't open Management Shell or Console - Reached limit of Powershell Concurrent Connections? Exchange Server Administration 3
R Exchange 2010 Sp1 install -> broken OWA -> broken powershell -> broken exchange managemen Exchange Server Administration 2
T How do I check litigationholdenabled flag via powershell Exchange Server Administration 3
E Remote PowerShell Error: Value cannot be null Exchange Server Administration 7
E Powershell 2.0 CTP3 On Exchange 2010 Exchange Server Administration 4
S Exchange 2010 Console and exchange powershell error Exchange Server Administration 8
M Powershell: condition not working Exchange Server Administration 13
M PowerShell Virtual Directory Error Exchange Server Administration 3
S Exchnage 2007 Powershell comandlet Exchange Server Administration 4
J Re: Exchange 2010 SP1 mailbox role install failure PowerShell virtual directory Exchange Server Administration 3
J Exchange 2010 SP1 mailbox role install failure PowerShell virtual directory Exchange Server Administration 5
G Open another user's Inbox/Mailbox via PowerShell (Outlook 2010 & Exchange 2010 SP1) Exchange Server Administration 6
S Exchange 2010 Management Powershell missing after installing SP1 Unable to load Exchange Server exshell.psc1 Exchange Server Administration 1
A What Powershell command must be used to set mAPIRecipient? Exchange Server Administration 3
B Exchange 2010 Management Powershell missing after installing SP1 Exchange Server Administration 4
T Unable to install SP1: "virtual directory 'PowerShell' already exists" Exchange Server Administration 8
S Powershell Script Help to create Mailboxes in Exchange 2010 Exchange Server Administration 1
M Powershell: Output as input & export Exchange Server Administration 8
M Powershell: Combine and Out-file Exchange Server Administration 2
J Exchange 2010 EMC and PowerShell Comandlets ACCESS DENIED Error Exchange Server Administration 3
Y Missing Powershell Virtual Application in IIS7.5 (W2K8R2) Exchange Server Administration 2
D Remote Powershell Exchange Edge Transport Server Exchange Server Administration 1
D How to add calendar enries to all users in organization using powershell and EWS. Exchange Server Administration 4
J Add secondary email address using Exchange 2010 powershell Exchange Server Administration 6
M WMI query for Get Disk IO performance in exchange Exchange Server Administration 0
B Select / activate first email item in the searched query Using Outlook 1
Q Mail account setup query Using Outlook 0
B query outlook using vba Outlook VBA and Custom Forms 13
T Query About "Delay Delivery" Function Using Outlook 6
Similar threads


















































Top