小编ED2*_*209的帖子

在PowerShell ISE中调用函数

有人能告诉我为什么我不能在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脚本中调用函数.有人可以帮忙吗?

powershell function call

12
推荐指数
1
解决办法
5万
查看次数

扫描仪对象 - 拆分字符串

我正在尝试使用Scanner对象将字符串输入写入文本文件.

字符串输入是电影名称.但是,如果文件名有两个单词,则扫描程序对象只接受第一个单词.

我需要它来接受这两个词.这是我的代码: -

Scanner new_dvd_info = new Scanner(System.in);

System.out.println("Enter name of new film");`          
String film_name = new_dvd_info.next();          
Run Code Online (Sandbox Code Playgroud)

请问有人放光吗?

java java.util.scanner

0
推荐指数
1
解决办法
93
查看次数

标签 统计

call ×1

function ×1

java ×1

java.util.scanner ×1

powershell ×1