PowerShell:接收错误 "The term '...' is not recognized as the name of a cmdlet, function, script file, or operable program"
PowerShell: Receiving error "The term '...' is not recognized as the name of a cmdlet, function, script file, or operable program"
我在尝试执行另一个文件中的 PowerShell 函数时遇到了大问题。
这是我的初始 .ps1 文件:
$scriptDir = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent
$file = Get-Item $scriptDir\JSONFile1.json
$plaintext = $file | Get-Content
.\Functions\Add-Folder.ps1 -AdlsAccountName "Hello World"
文件Add-Folder.ps1
包含以下内容:
[CmdletBinding()]
Param(
[Parameter(Mandatory=$True,Position=1)]
[string] $AdlsAccountName
)
Write-Host $AdlsAccountName
但是当我执行此 .ps1 脚本时,我收到以下错误:
##[error]The term '.\Add-Folder.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.
尝试在引用文件时加点:
. .\Functions\Add-Folder.ps1 -AdlsAccountName "Hello World"
这种技术称为点采购。
更多信息:
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_scripts
我在尝试执行另一个文件中的 PowerShell 函数时遇到了大问题。
这是我的初始 .ps1 文件:
$scriptDir = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent
$file = Get-Item $scriptDir\JSONFile1.json
$plaintext = $file | Get-Content
.\Functions\Add-Folder.ps1 -AdlsAccountName "Hello World"
文件Add-Folder.ps1
包含以下内容:
[CmdletBinding()]
Param(
[Parameter(Mandatory=$True,Position=1)]
[string] $AdlsAccountName
)
Write-Host $AdlsAccountName
但是当我执行此 .ps1 脚本时,我收到以下错误:
##[error]The term '.\Add-Folder.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.
尝试在引用文件时加点:
. .\Functions\Add-Folder.ps1 -AdlsAccountName "Hello World"
这种技术称为点采购。
更多信息: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_scripts