ED2*_*209 12 powershell function call
有人能告诉我为什么我不能在PowerShell脚本中调用函数吗?见下面我的代码:
Write-Host "Before calling Function."
testFunction
function testFunction()
{
Write-Host "Function has been called"
}
Run Code Online (Sandbox Code Playgroud)
当我运行上面的代码时,我收到以下错误消息:
testFunction : The term 'testFunction' 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 C:\Users\andrew.short\Documents\Powershell\Backups\functionTest.ps1:3 char:1 + testFunction + ~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (testFunction:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
我确信必须能够在同一个PowerShell脚本中调用函数.有人可以帮忙吗?
sod*_*low 23
您必须在使用之前声明该功能.
Write-Host "Before calling Function."
function testFunction {
Write-Host "Function has been called"
}
testFunction
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
48586 次 |
最近记录: |