Solved

powershell reading an array from a file into a command

Posted on 2013-12-06
6
319 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
  • 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 68

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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 68

Expert Comment

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

Author Comment

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

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Utilizing an array to gracefully append to a list of EmailAddresses
Synchronize a new Active Directory domain with an existing Office 365 tenant
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

758 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now