Skip to content

Instantly share code, notes, and snippets.

@joncloud
Created March 8, 2018 05:05
Show Gist options
  • Select an option

  • Save joncloud/381cb04a7243829c8d5060a4092d9410 to your computer and use it in GitHub Desktop.

Select an option

Save joncloud/381cb04a7243829c8d5060a4092d9410 to your computer and use it in GitHub Desktop.
$Expression = [regex] '^([^\s#]*)\s*([^\s#]*)\s*(#.*|)$'
Get-Content $env:windir\system32\Drivers\etc\services `
| ForEach-Object { $Expression.Match($_) } `
| ForEach-Object {
@{
Name = $_.Groups[1].Value;
Port = $_.Groups[2].Value;
Comment = $_.Groups[3].Value
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment