title: There are spaces in string, but I can't split it in powershell
body: <p>I want to compare user's groups and DFS's groups to find out if the user has access authority to DFS. but I got stuck in split string.</p>
  <p>here is part of my code:</p>
  <pre><code>$folder = Read-Host 'Enter the folder path'
  $User = Read-Host 'Enter the sAMAccountName of user'
  $getSGs = (get-acl $folder).Access | Select-Object -uniq -ExpandProperty IdentityReference 
  $getSGsSplit = $getSGs -split('.*\\')
  $arr = $getSGsSplit -split ' '
  Write-Host $arr
  </code></pre>
  <p>the value of $getSGs：</p>
  <pre><code>domain-ORG\xxx-Read domain-ORG\xxx-Modify domain-ORG\xxx-Admin domain-ORG\xxx-Center domain-ORG\xxxx-Admin BUILTIN\Administrators
  </code></pre>
  <p>the value of $getSGsSplit:</p>
  <pre><code> xxx-Read  xxx-Modify  xxx-Admin  xxx-Center  xxxx-Admin  Administrators 
  </code></pre>
  <p>What I Want is to split the $getSGsSplit by spaces:</p>
  <pre><code>xxx-Read
  xxx-Modify
  xxx-Admin
  xxx-Center  
  xxxx-Admin
  BUILTIN\Administrators 
  </code></pre>
  <p>BUT I have been tried lots of patterns, all of them doesn't work.</p>
  <pre><code>$getSGsSplit -split ' .-`t`n`r'
  $getSGsSplit -replace ' ','\n'
  $getSGsSplit.split(' ').trim()
  $getSGsSplit.split('\s').trim()
  $getSGsSplit -split ' '
  </code></pre>
  <p>And no matter which pattern I used , the console of <code>write-host $arr[2]</code> still were spaces. And console of <code>write-host $arr[2].getType()</code> always were System.String</p>
  <pre><code>PS C:\Users\zzz\Desktop&gt; C:\Users\zzz\Desktop\12.ps1
  Enter the folder path: \\domain.org\xxx\xx\xxx
  Enter the sAMAccountName of user: zzz
  
  
  PS C:\Users\zzz\Desktop&gt; 
  </code></pre>
  <p>Can anyone advise how to resolve this?</p>