header1   header
header
header Register : : Login header
header
connector   connector
menuleft menuright
submenu   submenu
left
You cannot call a method on a null-valued expression
Last Post 11 Feb 2010 05:38 PM by tony. 2 Replies.
Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
tonyUser is Offline
New Member
New Member
Posts:6
Avatar

--
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 RamnaniUser is Offline
    New Member
    New Member
    Posts:68
    Avatar

    --
    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
    tonyUser is Offline
    New Member
    New Member
    Posts:6
    Avatar

    --
    11 Feb 2010 05:38 PM
    Worked like a charm thans :-)
    You are not authorized to post a reply.


    Active Forums 4.3
    right
    footer   footer
    footer Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 R2 footer
    footer   footer