Powershell--Assistance

Anthony K O365
Anthony K O365 used Ask the Experts™
on
How can I get a csv listing of Alias' from a csv listing of Displaynames? Please provide the Powershell cmdlet.

Thank you!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Rajitha ChimmaniSpecialized Technology Analyst

Commented:
$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
AkhaterSolutions Architect

Commented:
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 ChimmaniSpecialized Technology Analyst

Commented:
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
Success in ‘20 With a Profitable Pricing Strategy

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

AkhaterSolutions Architect

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

Open in new window

IT Infrastructure Architect
Commented:
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

AkhaterSolutions Architect
Commented:
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

Anthony K O365Messaging Consulting

Author

Commented:
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?
AkhaterSolutions Architect

Commented:
Run my command it is the same but will give youthe names and aliases add the quota variables to it if you want
Anthony K O365Messaging Consulting

Author

Commented:
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 O365Messaging Consulting

Author

Commented:
This is what I needed.
AkhaterSolutions Architect

Commented:
You don't need quotes in the csv

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial