0

我有一个具有各种功能的模块。我最近添加了一个功能。该函数接受一个参数,处理一些数据并调用其中的另一个函数。该函数接受一个字符串数组作为参数。下面是代码:

        Function Get-CMClientInstall{
        some code..........

        Analyze-ClientInstall $clientcheck


        Function Analyze-ClientInstall
        {
            #[CmdletBinding()]

            PARAM (
            [Parameter(Mandatory=$true)][string[]]$CCMClients)
        }
     }

以下是错误消息:

The term 'Analyze-ClientInstall' 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:\Windows\system32\WindowsPowerShell\v1.0\Modules\ConfigMgrCommands\ConfigMgrCommands.psm1:475 char:34
+             Analyze-ClientInstall <<<<  $clientcheck
    + CategoryInfo          : ObjectNotFound: (Analyze-ClientInstall:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

有人可以请教吗?提前致谢。

4

1 回答 1

1

PowerShell 读取文件并同步执行内容。当您调用该函数时,PowerShell 不知道它存在,因为它还没有解释它。在函数声明之后移动到调用函数。

    Function Get-CMClientInstall{
    some code..........


    Function Analyze-ClientInstall
    {
        #[CmdletBinding()]

        PARAM (
        [Parameter(Mandatory=$true)][string[]]$CCMClients)
    }


    Analyze-ClientInstall $clientcheck
 }
于 2013-03-13T13:17:21.543 回答