Solved

Powershell--Assistance

Posted on 2012-12-21
11
238 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:Anthony K 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
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
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:Anthony K 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:Anthony K 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:Anthony K 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

Want Experts Exchange at your fingertips?

With Experts Exchange’s latest app release, you can now experience our most recent features, updates, and the same community interface while on-the-go. Download our latest app release at the Android or Apple stores today!

Question has a verified solution.

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

Auditing domain password hashes is a commonly overlooked but critical requirement to ensuring secure passwords practices are followed. Methods exist to extract hashes directly for a live domain however this article describes a process to extract u…
After hours on line I found a solution which pointed to the inherited Active Directory permissions . You have to give/allow permissions to the "Exchange trusted subsystem" for the user in the Active Directory...
In this video we show how to create an Address List in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Organization >> Ad…
In this video we show how to create a mailbox database in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Servers >> Data…
Suggested Courses

630 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