Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The argument 'install-sshed.ps1' to the -File parameter does not exist | powershell

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?

like image 620
Deepak-ranolia Avatar asked Nov 21 '25 10:11

Deepak-ranolia


2 Answers

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
like image 108
engineerer Avatar answered Nov 23 '25 06:11

engineerer


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

like image 35
Pixel Avatar answered Nov 23 '25 05:11

Pixel