Stuck on pointing a variable to running the exe. azcopy in PowerShell

Hi! Straight away I will point out I’m 100% newbie here. In one of my Pluralsight courses for Manage Data in Azure Storage. I have a chunk of PowerShell that has gotten the better of me. Most times I have pushed my way through issues and learned the hows and whys, but I can not win this time.

Can you please have a look at this and explain where and why this is not working.

PS C:\Users\kalka\OneDrive\Azure> $userenv = [system.environment]::getenvironmentvariable("path", "user")
PS C:\Users\kalka\OneDrive\Azure> [system.environment]::setenvironmentvariable("PATH", $userenv + "C:\Users\kalka\OneDrive\Azure\PowerShell\azcopy_windows_amd64_10.11.0", "user")

I then exit, open a new terminal window and get this when trying to access azcopy

PS C:\Users\kalka\OneDrive\Azure> azcopy
azcopy: The term 'azcopy' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

Thank you in advance and hopefully I have posted to the right area :slight_smile:

The system path is for executables. Powershell has $PSModulePath. Try adding it there.


Thank you that was precisely it.

My question to you now. If I’m giving the path, what is the difference if it is located within the PowerShell dir vs. any other location. In my mind, as long as it knows where then it should work. Which is obviously not the case.

Sorry for the follow-up. Just want to understand the logic.