Quantcast
Channel: Exchange Server 2013 - Administration, Monitoring, and Performance forum
Viewing all articles
Browse latest Browse all 9032

You cannot call a method with null-valued expresion

$
0
0

I'm having very weird behavior, I get above mentioned error running following simple command:

$user = get-mailbox JoeD | get-mailboxstatistics
$user.totalitemsize.value.toMB()

The issue is that if I run it from "Exchange PowerShell Console" (the one you get with installation of EX management tools) it works without problem and output is as expected number - size of user mailbox in MB. However If I run it from regular PS session where I imported Exchange snapin it doesn't work... (so it doesn't work from script, for example)

Where is the problem?

The all code of script that doesn't work:

$EXSession = new-PSSession -ConfigurationName Microsoft.Exchange -ConnectionURIhttp://cas.corp.com -authentication Kerberos

import-pssession $EXSession

Add-PSSnapin MIcrosoft.Exchange.Management.POwershell.E2010
. $env:ExchangeInstallPath\bin\RemoteExchange.ps1

connect-exchangeserver mailbox.corp.com

$user = get-mailbox kucerl | get-mailboxstatistics
$user.totalitemsize.value.toMB()




Viewing all articles
Browse latest Browse all 9032

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>