Removing White Spaces
hello all, have pretty simple script return usernames based off of full names being read in text file. regarding script, output has white space im having difficulty getting rid of. here script....
$users = get-content c:\users\user\desktop\names.txt
$results = foreach ($item in $users) {get-aduser -filter {name -eq $item} | select-object samaccountname}
$results | out-file c:\users\user\desktop\results.txt
i have attached screenshot of output looks in text file, can see when "select all" theres ton of white space after each result.
- please remember mark post's helpful if assist issue.
- please remember mark post's answer if provide answer issue.
at first glance, may want use select-object's -expandproperty parameter: ... | select-object -expandproperty samaccountname
edit: alexander's option work well, providing you're using powershell 3.0 or greater. dotted notation same thing -expandproperty parameter -- isolates property's value , rids of column header, underline, , excess spaces.
Windows Server > Windows PowerShell
Comments
Post a Comment