I have Powershell ISE open as Administrator. When I execute the script from the desktop (e.g. C:\Users\myUser\Desktop\CompareScripts\runCompareScript.ps1), the script works fine. However, when I execute from the C:\CompareScripts\runCompareScript.ps1 the script changes the file path to C:\Windows\system32\runCompareScript.ps1. Why is this occurring and how can I prevent this from happening?
Note: This is happening during the execution of a
invoke-sqlcmdstatement.

C:\windows..., you can use$pwdfor the current directory, to access data files in the user directory use:$env:UserProfile\Desktop\CompareScripts\foo.sqlYou may need to show more of your script for us to see what's going wrong.