0

I have a module with various functions. I recently added a function. This function accepts a parameter, processes some data and calls another function which is inside it. This function accepts a string array as a parameter. Below is the code:

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

        Analyze-ClientInstall $clientcheck


        Function Analyze-ClientInstall
        {
            #[CmdletBinding()]

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

Below is the error message:

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

Can someone please advice? Thanks in advance.

1 Answer 1

1

PowerShell reads the file and execute the content synchronously. When you call the function PowerShell doesn't have a clue that it exist cause it didn't interpret it yet. Move to call to the function AFTER the function declaration.

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


    Function Analyze-ClientInstall
    {
        #[CmdletBinding()]

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


    Analyze-ClientInstall $clientcheck
 }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.