title: If strings starts with in PowerShell
body: <p>Is there a way to check if a string starts with a string?</p>
  
  <p>We are checking the groupmembership from the <a href="http://en.wikipedia.org/wiki/Active_Directory" rel="noreferrer">AD</a> user. Our AD groups look like this: <code>S_G_share1_W</code></p>
  
  <p>The script for connecting the networkshares should only run if the groupname starts with <code>"S_G_"</code>, because we have some other groups too.</p>
  
  <pre><code>$GroupArray = Get-ADPrincipalGroupMembership $env:USERNAME | select samaccountname
  
  foreach ($Group in $GroupArray) {
  
      if ($Group.StartsWith("S_G_")) {
  
          $Group = $Group -replace "S_G_", $FileServerRV
          Write-Host $Group
  
          $Group = $Group.Substring(0, $Group.Length-2)
          Write-Host $Group
  
          #erstellen des Anzeigennames
          $Groupname = $Group.Replace($FileServerRV, "")
          Write-Host "Call Function with parameter "$Group $Groupname
      }
  }
  </code></pre>