Avatar of Anthony K O365
Anthony K O365
Flag for United States of America asked on

Powershell--Assistance

How can I get a csv listing of Alias' from a csv listing of Displaynames? Please provide the Powershell cmdlet.

Thank you!
ExchangePowershell

Avatar of undefined
Last Comment
Akhater

8/22/2022 - Mon
Rajitha Chimmani

$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
Akhater

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

Rajitha Chimmani

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
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
Akhater

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

Open in new window

ASKER CERTIFIED SOLUTION
SubSun

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
Akhater

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Anthony K O365

ASKER
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?
Akhater

Run my command it is the same but will give youthe names and aliases add the quota variables to it if you want
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Anthony K O365

ASKER
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?
Anthony K O365

ASKER
This is what I needed.
Akhater

You don't need quotes in the csv
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck