Register
: :
Login
Home
News
Forums
Scripts
User Groups
Resources
About
Forums
Search
Members
Unanswered
Active Topics
Forums
>
Using PowerShell
>
Exchange Server
You cannot call a method on a null-valued expression
Last Post 11 Feb 2010 05:38 PM by
tony
. 2 Replies.
Sort:
Oldest First
Most Recent First
Prev
Next
You are not authorized to post a reply.
Author
Messages
tony
New Member
Posts:6
08 Feb 2010 03:26 AM
All,
Having an issue with a script i am creating to grab vaules from Exchange and dump these to a html through out the script i am using a variable $target i keep getting null value expressions aplologies but i really cant figure it out also after some advice from experts.
here's the error.
You cannot call a method on a null-valued expression At D:\APPS\Report\Script\target3.ps1:960 char:99
I am currently looking at 2 bits of code i've found and modified basically i want to use the $target variable which will grab the server name and provide to the -server or -id field and provide a list of 20 mailboxes sorted by size in mb
$Biggest20 = get-mailboxserver -id $target | get-mailboxdatabase | Get-Mailbox -resultsize unlimited | Get-MailboxStatistics | sort-object -Property totalitemsize -des | select-object Displayname, @{Name="Total Size (MB)";expression={(get-mailboxstatistics $_).totalitemsize.value.toMB()}} -first 20
Get-MailboxStatistics -server $target | sort-object -Property totalitemsize -des | select-object Displayname, @{Name="Total Size (MB)";expression={(get-mailboxstatistics $_).totalitemsize.value.toMB()}} -first 20
Apart from the issue above which powershell command would be the best???
Thanks to all for assistance.
Vishal Ramnani
New Member
Posts:68
08 Feb 2010 03:38 AM
Just remove Get-Mailboxstatistics from Expression in Select-Object because the value is already carried to this cmdlet from pipeline. so it will be like this.
Get-MailboxStatistics -server $target | sort-object -Property totalitemsize -des | select-object Displayname, @{Name="Total Size (MB)";expression={$_.totalitemsize.value.toMB()}} -first 20
And since both will return same kind of results so use the second one because less number of queries to DC and MBx servers.
Thanks.
Vishal Ramnani
MCITP - Exchange 2007,
MCSE Messaging,
MCTS - Win 2008 Config
tony
New Member
Posts:6
11 Feb 2010 05:38 PM
Worked like a charm thans :-)
You are not authorized to post a reply.
Using PowerShell
--General PowerShell
--Active Directory
--Exchange Server
--Lync Server
--SharePoint
--SQL Server
--System Center
--Non-Microsoft Products
--Books, Tools, and Videos
--Working with .NET
--Peer Review
--Testing, Testing...
PowerShell Development
--Cmdlet Development
--PSDrive Provider Development
--Hosting the Shell
Looking Ahead
--Using PowerShell v2.0
--Developing for PowerShell v2.0
PowerShellCommunity.org
--Community Announcements and Assistance
--Completely Unrelated
--User Groups
--Community Business
----Suggestion Box
Forums
>
Using PowerShell
>
Exchange Server
Active Forums 4.3
Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 R2