INFORMATICS

The Best

Przełącznik języka

Zaproś mnie na KAWE

Jeżeli podoba Ci się strona i chcesz wspomóc projekt!

Postaw mi kawę na buycoffee.to

This Site

Płatnik

CMS

Hardware

Uncategorised

Emulators

Powershell

Storage Array

DNS

Antivirus program

Licznik

2.png9.png0.png6.png2.png4.png3.png
Today90
Yesterday551
This week3457
This month5216
Total2906243

Visitor Info

  • IP: 3.147.36.213
  • Browser: Unknown
  • Browser Version:
  • Operating System: Unknown

Who Is Online

4
Online

sobota, 11 maj 2024 04:54

Error: The term 'test.ps1' is not recognized as the name of a cmdlet

Ocena użytkowników: 5 / 5

Gwiazdka aktywnaGwiazdka aktywnaGwiazdka aktywnaGwiazdka aktywnaGwiazdka aktywna
 

Error

The term 'test.ps1' 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.

When running a script like ./Test.ps1 the script is expected to be in the current working directory (.).

Depending on the environment from which you're executing that statement the working directory may not be what you expect, though.

Here are some commands that allow you to determine the current working directory when run the same way as your script:

$PWD.Path
(Get-Location).Path
(Resolve-Path '.').Path

There are basically 3 ways to deal with the issue:

  • Specify the path to your PowerShell script relative to the current working directory.
  • Change the current working directory to the location of the PowerShell script:

    Push-Location 'C:\temp\folder'
    .\Test.ps1
    Pop-Location
  • Run the PowerShell script with its full path:

    & 'C:\temp\folder\Test.ps1'

    If the executable's filename, path, or pathname doesn't contain spaces, using the call (&) operator is optional. Otherwise, the call operator is required.

Search