在PowerShell 2.0中需要参数的函数内调用函数
我有一个具有各种功能的模块。我最近添加了一个函数。此函数接受一个参数,处理一些数据并调用其中的另一个函数。此函数接受字符串数组作为参数。代码如下:在PowerShell 2.0中需要参数的函数内调用函数,powershell,Powershell,我有一个具有各种功能的模块。我最近添加了一个函数。此函数接受一个参数,处理一些数据并调用其中的另一个函数。此函数接受字符串数组作为参数。代码如下: Function Get-CMClientInstall{ some code.......... Analyze-ClientInstall $clientcheck Function Analyze-ClientInstall { #[C
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
术语“Analyze ClientInstall”不能识别为cmdlet、函数、脚本文件或可操作程序的名称。
请检查名称的拼写,或者如果包含路径,请验证路径是否正确,然后重试。
位于C:\Windows\system32\WindowsPowerShell\v1.0\Modules\ConfigMgrCommands\ConfigMgrCommands.psm1:475 char:34
+Analyze ClientInstallPowerShell读取文件并同步执行内容。当您调用函数PowerShell时,它并不知道它是否存在,因为它还没有解释它。移动以在函数声明后调用函数
Function Get-CMClientInstall{
some code..........
Function Analyze-ClientInstall
{
#[CmdletBinding()]
PARAM (
[Parameter(Mandatory=$true)][string[]]$CCMClients)
}
Analyze-ClientInstall $clientcheck
}