我是PS的新手,已经获得了一个可以运行的脚本.我做的第一件事是输入c:\powershell\ir.ps1.这似乎有效.然后在定义我的客户端目录之后,我应该只能输入诸如的函数ir-n.这在人员的办公桌上工作,告诉我该怎么做,但是我收到以下错误:
The term 'ir-n' 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 line:1 char:5
+ ir-n <<<<
+ CategoryInfo : ObjectNotFound: (ir-n:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Run Code Online (Sandbox Code Playgroud)
有什么简单的我可以做到让它运行?我看到ir.ps1文件中的函数,所以我知道它在那里.
ir.ps1当你应该采购它时,看起来你正在运行脚本.我猜这个ir.ps1文件正在定义一个名为的函数ir-n.在这种情况下,运行脚本不会在脚本的上下文中定义函数,也不会在命令窗口中定义函数.您需要获取脚本以使其在命令窗口中保留.
尝试运行以下内容
PS$> . c:\powershell\ir.ps1
Run Code Online (Sandbox Code Playgroud)
运行后再尝试ir-n.
| 归档时间: |
|
| 查看次数: |
16814 次 |
| 最近记录: |