3
A
回答
7
可以使函数本身重新写,基本上成为首调用后一个空操作:
function TestFunction
{
'Do Stuff'
function Script:TestFunction { Return }
}
1
像这样的东西可以帮助你:
function A
{
Write-Host "calling function A"
}
function B
{
Write-Host "calling function B"
}
function C
{
Write-Host "calling function C"
}
function All
{
A
if (!$script:BHasBeenCalled)
{ B }
C
}
Get-PSBreakpoint | Remove-PSBreakpoint
Set-PSBreakpoint -Command B -Action { $script:BHasBeenCalled = $true } | Out-Null
$script:bHasBeenCalled = $false
#First call: B should be invoked
All
#Second call: B shouldn't be invoked
All
-1
如果该功能已经被称为,它被加载并出现在函数Ps驱动器中。
function test1 {
# define a function
function test2 {return}
# call it
test2
# check it was called
dir function:\test2
}
test1
相关问题
- 1. 如何正确调用powershell函数?
- 2. 如何确定数组是否已满
- 3. 如何确定函数是否为空
- 4. PowerShell是后函数调用
- 5. 如何使用已定义的参数(toHaveBeenCalledWith)测试函数是否被调用
- 6. 如何验证在Golang中是否调用特定函数
- 7. 如何确定UIView是否已加载
- 8. 如何确定CKEditor是否已加载?
- 9. 如何确定一个dll是否已经用我的C++函数注册过?
- 10. 如何确定函数是否存在于POSIX shell中?
- 11. 如何确定数据网格中的列是否已排序。
- 12. 如何检查一个函数是否已经在java中调用?
- 13. 在JavaScript函数中确定调用div
- 14. 调用Powershell函数
- 15. 如何确定DataGrid行是否已在MVVM中更改?
- 16. 如何确定文件是否已在StorageFolder中创建
- 17. 如何确定子窗口是否已在javascript中关闭?
- 18. 确定是否PowerShell脚本已经点源
- 19. 如何正确检查回调是否是箭头函数?
- 20. 在MFC中调用OnInitDialog函数后是否有任何函数?
- 21. 如何超时PowerShell函数调用
- 22. 确定函数调用是否为静态
- 23. 在新线程powershell中调用函数
- 24. 在powershell中调用函数时出错
- 25. 在PowerShell中调用函数的条件
- 26. 如何确定运行时是否存在Perl函数?
- 27. 确定widget是否已启用
- 28. 如何使用P/Invoke在PowerShell 1.0中调用Win32函数?
- 29. 如何确定参数是否已从Java“发布”或“创建”?
- 30. 如何确定数据库是否已更改?
太棒了!那就是我一直在寻找的东西。简单的东西,谢谢! –
这似乎对整个PowerShell会话都有效?有没有办法可以检查每个脚本运行,即使在相同的PowerShell会话? –
您是在ISE中测试还是在实际的Powershell控制台会话中测试?脚本:TestFunction应该将其隔离为当前脚本的范围,但是在ISE中的范围作用有点不同。 – mjolinor