Powershell 2.0 Powershell脚本-按函数组织脚本
当我将函数Powershell 2.0 Powershell脚本-按函数组织脚本,powershell-2.0,Powershell 2.0,当我将函数{}放在我的powershell脚本周围以更改注册表项时,脚本似乎没有在括号内运行。当我取出函数{}时,脚本运行良好。我错过了什么 Function ClearPageFile { $regpath = "HKLM:\SYSTEM....(rest of path)" $key = "ClearPageFileAtShutdown Set-ItemProperty -Path $regpath -Name $key -Value 0 } 除非你在别的地方调用函数,这
{}
放在我的powershell脚本周围以更改注册表项时,脚本似乎没有在括号内运行。当我取出函数{}时,脚本运行良好。我错过了什么
Function ClearPageFile
{
$regpath = "HKLM:\SYSTEM....(rest of path)"
$key = "ClearPageFileAtShutdown
Set-ItemProperty -Path $regpath -Name $key -Value 0
}
除非你在别的地方调用函数,这里是你的答案
Function ClearPageFile
{
$regpath = "HKLM:\SYSTEM....(rest of path)"
$key = "ClearPageFileAtShutdown
Set-ItemProperty -Path $regpath -Name $key -Value 0
}
#call the function
ClearPageFile
函数
只需创建(不执行)函数。如何执行该函数?我有大约十个,我会一个接一个的。你如何在你的脚本中调用你的函数?当你调用“ClearPageFile”时会发生什么?这就是我不知道该怎么做的。如果在一个脚本中有多个类似的函数,如何设置脚本以运行所有函数?