Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

powershell array will not run

Posted on 2014-08-21
5
Medium Priority
?
219 Views
Last Modified: 2014-08-21
I am trying to run this over each OU but for some reason this is failing and I have attached the error below. Please help as I am not an expert in powershell.


@(
contoso.local\toys
contoso.local\radios
contoso.local\beer
contoso.local\computers
contoso.local\users
) | % {

get-mailbox -organizationalunit $_  | select displayname, alias, identity

}



Error I receive below.


 The module 'contoso.local' could not be loaded. For more information, run 'Import-Module
'contoso.local' .
At C:\temp\nameofscript.ps1:5 char:1
+ 'contoso.local\toys'
0
Comment
Question by:techdrive
  • 2
  • 2
5 Comments
 
LVL 25

Expert Comment

by:Zephyr ICT
ID: 40276785
0
 
LVL 40

Expert Comment

by:Subsun
ID: 40276799
Use quotes to define strings, Also you need to use forward slash between OU names.. Try..
@(
"contoso.local/toys"
"contoso.local/radios"
"contoso.local/beer"
"contoso.local/computers"
"contoso.local/users"
 ) | % {

 get-mailbox -organizationalunit $_  | select displayname, alias, identity

 }

Open in new window

Hope you are running the code from EMS.
0
 

Author Comment

by:techdrive
ID: 40276905
thanks but now I am getting the followng error


Couldn't find organizational unit "contoso.local\toys". Make sure you have typed the name correctly.
At line:6 char:1
+ get-mailbox -organizationalunit $_  | select displayname, alias, identity
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], ManagementObjectNotFoundException
0
 
LVL 40

Accepted Solution

by:
Subsun earned 2000 total points
ID: 40276920
use forward slash

"contoso.local/toys"
0
 

Author Comment

by:techdrive
ID: 40277054
awesome thanks
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

If something goes wrong with Exchange, your IT resources are in trouble.All Exchange server migration processes are not designed to be identical and though migrating email from on-premises Exchange mailbox to Cloud’s Office 365 is relatively simple…
Stellar Exchange Toolkit: this 5 in 1 toolkit comes loaded with mega-software tool. Here’s an introduction to tools’ usage and advantages:
To show how to generate a certificate request in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.:  First we need to log into the Exchange Admin Center. Navigate to the Servers >> Certificates…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Suggested Courses

810 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