Solved

Trim with Powershell

Posted on 2015-01-23
2
129 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 16

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Why would I want to create a function for tracking messages? I am glad you asked. As with most monotonous/routine tasks, human error tends to creep in after doing the same task over and over again. By creating a function, you load the function onceā€¦
This article will help you understand what HashTables are and how to use them in PowerShell.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

706 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

19 Experts available now in Live!

Get 1:1 Help Now