无法在 Powershell 中调用函数,但可以使用 Powershell ISE
Can not call Function in Powershell but can with Powershell ISE
我无法在没有 PowerShell ISE 的情况下调用脚本内函数
当我在普通的 Powershell 中调用函数时出现此错误
onboarding : The term "onboarding" was not used as the name of a cmdlet, function, script file, or
of an executable program. Check the spelling of the name or if the path is correct (if
included) and repeat the process.
In *************************************.ps1:8 characters:9
+ onboarding
+ ~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (onboarding:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
记住 (对 ▶
按钮也有效):
When you use F5 to run a script in ISE, it doesn't actually
invoke the script, it executes the contents of the editor in the
global scope of the attached console/runspace, so it'll persist after
the first attempt.
运行 您的脚本使用 Dot sourcing operator .
Runs a script in the current scope so that any functions, aliases, and
variables that the script creates are added to the current scope,
overriding existing ones. Parameters declared by the script become
variables. Parameters for which no value has been given become
variables with no value. However, the automatic variable $args
is
preserved.
Example:
. c:\scripts\sample.ps1 1 2 -Also:3
Note. The dot sourcing operator is followed by a space. Use the space
to distinguish the dot from the dot (.
) symbol that represents the
current directory.
我无法在没有 PowerShell ISE 的情况下调用脚本内函数
当我在普通的 Powershell 中调用函数时出现此错误
onboarding : The term "onboarding" was not used as the name of a cmdlet, function, script file, or
of an executable program. Check the spelling of the name or if the path is correct (if
included) and repeat the process.
In *************************************.ps1:8 characters:9
+ onboarding
+ ~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (onboarding:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
记住 ▶
按钮也有效):
When you use F5 to run a script in ISE, it doesn't actually invoke the script, it executes the contents of the editor in the global scope of the attached console/runspace, so it'll persist after the first attempt.
运行 您的脚本使用 Dot sourcing operator .
Runs a script in the current scope so that any functions, aliases, and variables that the script creates are added to the current scope, overriding existing ones. Parameters declared by the script become variables. Parameters for which no value has been given become variables with no value. However, the automatic variable
$args
is preserved.Example:
. c:\scripts\sample.ps1 1 2 -Also:3
Note. The dot sourcing operator is followed by a space. Use the space to distinguish the dot from the dot (
.
) symbol that represents the current directory.