Solved

Trim with Powershell

Posted on 2015-01-23
2
142 Views
Last Modified: 2015-01-23
I am trying to return the groups that a user is part of. When I get the results, often there is extra spaces to the right of the results. I would like to trim those off. Is there a way to use trim() functionality for the following line?

Get-ADPrincipalGroupMembership <user> | select name
0
Comment
Question by:stakor
2 Comments
 
LVL 17

Accepted Solution

by:
Learnctx earned 500 total points
ID: 40566231
You will need to do one of the following.

Get-ADPrincipalGroupMembership <user> | Select -Expand Name | Foreach-Object {$_.trim()}

Or

Get-ADPrincipalGroupMembership <user> | Select @{name="Name";Expression={($_.name).trim()}}
0
 

Author Closing Comment

by:stakor
ID: 40566237
Works wonderfully.
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Utilizing an array to gracefully append to a list of EmailAddresses
In this previous article (https://oddytee.wordpress.com/2016/05/05/provision-new-office-365-user-and-mailbox-from-exchange-hybrid-via-powershell/), we made basic license assignments to users in O365. When I say basic, the method is the simplest way …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

810 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