Solved

powershell reading an array from a file into a command

Posted on 2013-12-06
6
325 Views
Last Modified: 2013-12-11
I have users who need certain aliases removed. Like the example Microsoft uses http://technet.microsoft.com/en-us/library/bb123794(v=exchg.150).aspx on their technet site removing aliases from a user but except I would like to remove them from a file. I am just beginning to learn about arrays and they are very handy with something like this


Set-Mailbox "Janet Schorr" -EmailAddresses @{remove="janet.schorr@corp.contoso.com","janets@tailspintoys.com"}

So I wondered and I know I am missing info but would like to try something like this

$emaillist=get-content c:\emailalias.csv

foreach($i in $emaillist) {

set-mailbox "janet schorr" -emailaddresses @{remove=and this is where I am list}

}
0
Comment
Question by:techdrive
[X]
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
  • 3
  • 2
6 Comments
 
LVL 13

Expert Comment

by:Felix Leven
ID: 39700876
I use somthing like this to work with data from an CVS file

Get-Content C:\test.csv | ConvertFrom-Csv -Delimiter ";" | Out-GridView

maybe you are missing just the delimiter or need to convert the data.
0
 
LVL 69

Expert Comment

by:Qlemo
ID: 39700944
MrGraves, instead of that, just use
Import-CSV -Delimiter ';' C:\test.csv | Out-GridView

Open in new window

No need to do more.

techdrive, I'm not clear about what exactly is in the CSV file. Is it just a comma-separatated list of aliasses you want to remove from a single account (which doesn't make much sense that way), or more of:
Account; Alias
"Janet schorr", "janet.schorr@corp.contoso.com,janets@tailspintoys.com"

Open in new window

0
 

Author Comment

by:techdrive
ID: 39700960
I am sorry the list of aliases are like this


alias1@contoso.local
alias2@contoso.local
alias3@contoso.local
alias4@contoso.local
so on and so on.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 69

Expert Comment

by:Qlemo
ID: 39701080
And all for a single account?
0
 

Author Comment

by:techdrive
ID: 39701331
no multiple accounts
0
 
LVL 69

Accepted Solution

by:
Qlemo earned 500 total points
ID: 39701604
If you insist (it is easier than you might think):
Set-Mailbox "Janet Schorr" -EmailAddresses @{remove=get-content c:\emailalias.csv}

Open in new window

0

Featured Post

Backup Solution for AWS

Read about how CloudBerry Backup fully integrates your backups with Amazon S3 and Amazon Glacier to provide military-grade encryption and dramatically cut storage costs on any platform.

Question has a verified solution.

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

Synchronize a new Active Directory domain with an existing Office 365 tenant
Windows 10 came with  a lot of built in applications, Some organisations leave them there, some will control them using GPO's. This Article is useful for those who do not want to have any applications in their image (example:me).
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the adminiā€¦

733 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