I am adding key to windows 7 x64 using powershell
So far i have tried the below command using powershell
powershell -executionpolicy bypass -file install-sshed.ps1
I got error like this:
The argument 'install-sshed.ps1' to the -File parameter does not exist. Provide the path to an existing '.ps1' file as an argument to the -File parameter
What i am doing wrong?
It seems like your PowerShell session is started in a different folder than your PowerShell script. Try to add the full path to your PowerShell script:
powershell -executionpolicy bypass -file "c:\scripts\install-sshed.ps1"
Alternatively, change to the directory where the *.ps1 file is located first:
cd c:\scripts
powershell -executionpolicy bypass -file install-sshed.ps1
In addition to the above answer, I'd like to add that you can also use relative paths.
For instance, to run from current directory
powershell -execution policy unrestricted -file ".\test.ps1"
Or to run from nested folder:
powershell -execution policy unrestricted -file ".\config\test.ps1"
I will also recommend to add the following parameter: -noprofile
This will make sure no user profiles will be loaded, it is a best practice to do that when running scripts.
You can find an interesting read here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With