PowerShell: Using $env:userprofile in an 'IF' statement PowerShell: Using $env:userprofile in an 'IF' statement powershell powershell

PowerShell: Using $env:userprofile in an 'IF' statement


On Windows 7:

[PS]> echo $ENV:UserProfileC:\Users\arco444

This returns the path to the profile directory. Therefore I'd expect looking only for the username to fail the condition. I'd do a simple match instead:

if ($env:userprofile -imatch "rmullins"){    Remove-Item $env:userprofile\Desktop\ITFILES -Recurse -Force}