[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now


Exchange 2007 Management Shell

Posted on 2013-11-10
Medium Priority
Last Modified: 2014-03-12
I have attached script, previously it was work just fine. Lately, we get below error generated for every mailbox before the it generated report file.

You cannot call a method on a null-valued expression.
At line:17 char:72
+     If ($Script:GroupList.ContainsKey($ADObject.sAMAccountName.ToString( <<<< ) + "\") -

eq $False)
You cannot call a method on a null-valued expression.
At line:22 char:72
+     If ($Script:GroupList.ContainsKey($ADObject.sAMAccountName.ToString( <<<< ) + "\" + 

You cannot call a method on a null-valued expression.

Open in new window

Question by:suriyaehnop
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
  • 2

Assisted Solution

FutureTechSysDOTcom earned 600 total points
ID: 39637918
For a test, try eliminating all of the stuff in ToString() and use a manual value.  There were some service packs released recently for Exchange 2007, that could have affected some things.  If you can get it working by using a manual value rather than using the ToString() function then you will know it is just a syntax issue.

Chris M.
**Advertising deleted by Netminder 11 Nov 2013**
LVL 31

Expert Comment

ID: 39638563
Any chance we could see more of the script? I don't see it attached.
LVL 19

Author Comment

ID: 39643439
sorry forgot to attached the full script. I did use this script and run on my Exchange 2010 lab, it working fine but error appeared on my company Exchange 2007 SP2
LVL 31

Accepted Solution

LeeDerbyshire earned 600 total points
ID: 39644249
Does it crash out on the first mailbox, or does it get part of the way through the Get-Mailbox results before crashing? Try adding


as the first line inside the foreach loop. I think that should be enough to display each mailbox display name, so that you can see if it processes any at all.
LVL 19

Author Comment

ID: 39654429
does it get part of the way through the Get-Mailbox results before crashing.

Where to add Try adding $mbx.DisplayName?

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

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

The main intent of this article is to make you aware of ‘Exchange fail to mount’ error, its effects, causes, and solution.
With so many activities to perform, Exchange administrators are always busy in organizations. If everything, including Exchange Servers, Outlook clients, and Office 365 accounts work without any issues, they can sit and relax. But unfortunately, it…
In this Micro Video tutorial you will learn the basics about Database Availability Groups and How to configure one using a live Exchange Server Environment. The video tutorial explains the basics of the Exchange server Database Availability grou…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.
Suggested Courses

649 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