0

This TechNet page says the location of a console profile file for the current user only and all shells shall be:

%UserProfile%\Documents\Windows­PowerShell\profile.ps1

In my case, the %UserProfile% points to:

 C:\Users\vlastimil

So, I created the following file:

C:\Users\vlastimil\Documents\Windows­PowerShell\profile.ps1

Which at this very moment contains 2 functions:

function sha256sum([string]$arg) {
    (Get-FileHash -Algorithm SHA256 $arg | Select -ExpandProperty Hash).ToLower()
}

function sha512sum([string]$arg) {
    (Get-FileHash -Algorithm SHA512 $arg | Select -ExpandProperty Hash).ToLower()
}

But calling these functions throws an error:

PS C:\Users\vlastimil> sha512sum
sha512sum : The term 'sha512sum' is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ sha512sum
+ ~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (sha512sum:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

As I know very little of Windows, I don't know where the problem is.


OS: Windows 10 Pro 1709

1

Profile location revealed with:

echo $PROFILE
C:\Users\vlastimil\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1

Thus, after changing the path + name, the problem has been solved.

0

There is a difference if you are running powershell console, or powershell ISE.

https://blogs.technet.microsoft.com/heyscriptingguy/2012/05/21/understanding-the-six-powershell-profiles/

Where you put your profile will only work when run from the console. ISE will not see or use this profile.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.