Solved

Powershell--Assistance

Posted on 2012-12-21
11
237 Views
Last Modified: 2012-12-21
How can I get a csv listing of Alias' from a csv listing of Displaynames? Please provide the Powershell cmdlet.

Thank you!
0
Comment
Question by:K Anthony O365
[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
  • 5
  • 3
  • 2
  • +1
11 Comments
 
LVL 16

Expert Comment

by:Rajitha Chimmani
ID: 38712913
$stuff = @()
$stuff = foreach($entry in import-csv inputfilename.csv){Get-Mailbox $entry.displayname | Select Alias}
$stuff | Export-Csv outputfilename.csv -notypeinformation

Your input csv file should be something like:
Displayname
User1
User2
0
 
LVL 49

Expert Comment

by:Akhater
ID: 38712914
assuming your csv is something like

Name
Joe Took
Micheal Kain

Open in new window


it would be something like

$a = import-csv c:\list.csv
$a | Get-Mailbox $_.name| select name, alias

Open in new window

0
 
LVL 16

Expert Comment

by:Rajitha Chimmani
ID: 38712920
You can also use the following lines of code

foreach($entry in import-csv inputfilename.csv){Get-Mailbox $entry.displayname} | Select Alias | Export-csv outputfilename.csv -Notypeinformation
0
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
LVL 49

Expert Comment

by:Akhater
ID: 38712927
sorry that's
$a = import-csv c:\list.csv
$a | foreach {Get-Mailbox $_.name}| select name, alias

Open in new window

0
 
LVL 40

Accepted Solution

by:
Subsun earned 250 total points
ID: 38712931
Following command will only export the Alias. If you want more attributes in output then add it in select section and export it..
CSV header should be Displaynames
Import-csv test.csv | % {Get-recipient $_Displaynames | Select Alias} | Export-Csv c:\test.csv -NoTypeInformation

Open in new window

0
 
LVL 49

Assisted Solution

by:Akhater
Akhater earned 250 total points
ID: 38712940
csv is like

Name
Joe Took
Micheal Kain

Open in new window


the powershell is like
$a = import-csv c:\list.csv
$a | foreach {Get-Mailbox $_.name}| select name, alias | export-csv c:\alias.csv

Open in new window

0
 

Author Comment

by:K Anthony O365
ID: 38713497
Now I am trying to run this cmdlet, but it is outputting the quota values and not the names. Am I missing a variable? The csv is:

Name
user1
user2

Import-csv d:\displayname.csv

%{Get-mailbox $_.Name} |select-object prohibitsendquota, issuewarningquota, prohibitsendreceivequota |export-csv D:\QuotaLimit.csv

Any thoughts?
0
 
LVL 49

Expert Comment

by:Akhater
ID: 38713516
Run my command it is the same but will give youthe names and aliases add the quota variables to it if you want
0
 

Author Comment

by:K Anthony O365
ID: 38713662
Here is what's happening: When I add quotes around the displaynames ("john smith") and save it as csv, when I open in notepad, it shows triple quotes around the names ("""john smith"""). Some how the formatting is wrong when I save it. Even when I save it as a text file, it still shows triple quotation marks.

Any thoughts?
0
 

Author Closing Comment

by:K Anthony O365
ID: 38713682
This is what I needed.
0
 
LVL 49

Expert Comment

by:Akhater
ID: 38713694
You don't need quotes in the csv
0

Featured Post

Industry Leaders: 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!

Question has a verified solution.

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

Lotus Notes – formerly IBM Notes – is an email client application, while IBM Domino (earlier Lotus Domino) is an email server. The client possesses a set of features that are even more advanced as compared to that of Outlook. Likewise, IBM Domino is…
In previous parts of this Nano Server deployment series, we learned how to create, deploy and configure Nano Server as a Hyper-V host. In this part, we will look for a clustering option. We will create a Hyper-V cluster of 3 Nano Server host nodes w…
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

752 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