Solved

Powershell--Assistance

Posted on 2012-12-21
11
235 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
  • 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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
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

Does Powershell have you tied up in knots?

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

Question has a verified solution.

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

Following basic email etiquette rules will help you write a professional email and achieve a good, lasting impression with your contacts.
Learn to move / copy / export exchange contacts to iPhone without using any software. Also see the issues in configuration of exchange with iPhone to migrate contacts.
The video tutorial explains the basics of the Exchange server Database Availability groups. The components of this video include: 1. Automatic Failover 2. Failover Clustering 3. Active Manager
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…

832 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