Solved

Powershell--Assistance

Posted on 2012-12-21
11
233 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:kt KTAdmin
  • 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
 
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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
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:kt KTAdmin
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:kt KTAdmin
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:kt KTAdmin
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

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

Follow this checklist to learn more about the 15 things you should never include in an email signature from personal quotes, animated gifs and out-of-date marketing content.
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this video we show how to create an email address policy 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 Mail Flow…
The basic steps you have just learned will be implemented in this video. The basic steps are shown to configure an Exchange DAG in a live working Exchange Server Environment and manage the same (Exchange Server 2010 Software is used in a Windows Ser…

744 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

11 Experts available now in Live!

Get 1:1 Help Now