Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

powershell reading an array from a file into a command

Posted on 2013-12-06
6
Medium Priority
?
332 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 71

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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 71

Expert Comment

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

Author Comment

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

Accepted Solution

by:
Qlemo earned 2000 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

Introducing the WatchGuard 420 Access Point

WatchGuard's newest access point includes an 802.11ac Wave 2 chipset, providing the fastest speeds for VoIP, video and music streaming, and large data file transfers. Additionally, enjoy the benefits of strong security as the 3rd radio delivers dedicated WIPS protection!

Question has a verified solution.

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

This article will help you understand what HashTables are and how to use them in PowerShell.
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…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

705 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