title: How do you delete user profiles in powershell?
body: <p>I am writing a powershell script to delete user profiles and I understand the method I am using is not the best. I was wondering what would be a better way to do it? I am still very much new to powershell but I am willing to learn</p>
  
  <p>The code I already have:</p>
  
  <pre><code>$ErrorActionPreference= 'silentlycontinue'
  $Users = Get-WmiObject -Class Win32_UserProfile
  $IgnoreList = "helpdesk", "administrator", "Default"
  
  :OuterLoop
  foreach ($User in $Users) {
      foreach ($name in $IgnoreList) {
          if ($User.localpath -like "*\$name") {
              continue OuterLoop
          }
      }
  
      $User.Delete()
  }
  </code></pre>