troubleshooting Question

PowerShell insert brake after each returned object

Avatar of MRS
MRSFlag for United States of America asked on
Powershell
3 Comments1 Solution265 ViewsLast Modified:
Hi,
I have PowerShell script that returns members of local admin group on remote PC's, however I am trying to insert a brake for each group. Example:
Script:
function get-localadmin {
$computer = Get-Content C:\Computers\computers.txt
$admins = Gwmi win32_groupuser –computer $computer  
$admins = $admins |? {$_.groupcomponent –like '*"Administrators"'}
$admins | % {$_.partcomponent –match “.+Domain\=(.+)\,Name\=(.+)$” > $null
$matches[1].trim('"') + “\” + $matches[2].trim('"')
}
}
get-localadmin | Out-File C:\Computers\members.txt

Result:
PC6666\localadmin
PC6666\MRSUser
CORP\$Desktop Support
CORP\Domain Admins
PC7777\localadmin
PC7777\MRSUser
CORP\$Desktop Support
CORP\Domain Admins
PC9999\LocalAdmin
PC9999\MRSUser
CORP\$Desktop Support
CORP\Domain Admins
etc.

I need to insert a brake after each group so it returns in a better to read format. Example:

PC6666\localadmin
PC6666\MRSUser
CORP\$Desktop Support
CORP\Domain Admins

PC7777\localadmin
PC7777\MRSUser
CORP\$Desktop Support
CORP\Domain Admins

PC9999\LocalAdmin
PC9999\MRSUser
CORP\$Desktop Support
CORP\Domain Admins



Any suggestions are appreciated.
ASKER CERTIFIED SOLUTION
David Johnson, CD
The More I know, the more I don't know
Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros