我在Main中调用“Del”函数并要求我删除该文件夹。当我重命名为“删除”时,它正如我预期的那样正常工作。只是想知道“Del”是否是PS中的保留关键字。
代码:
function Main {
#Delete the entire folder instead going into Del function
Del $Path
}
function Del ($DropLocation) {
# code...
}
谢谢!
答案 0 :(得分:2)
Del不是关键字,但它是cmdlet Remove-Item
的别名。根据(http://technet.microsoft.com/en-us/library/hh849765.aspx)处的文档,以下命令对同一cmdlet别名:
如果执行命令Get-Help about_Language_Keywords
,则会看到以下保留字。
Keyword Reference
------- ---------
Begin about_Functions, about_Functions_Advanced
Break about_Break, about_Trap
Catch about_Try_Catch_Finally
Continue about_Continue, about_Trap
Data about_Data_Sections
Do about_Do, about_While
Dynamicparam about_Functions_Advanced_Parameters
Else about_If
Elseif about_If
End about_Functions, about_Functions_Advanced_Methods
Exit Described in this topic.
Filter about_Functions
Finally about_Try_Catch_Finally
For about_For
Foreach about_Foreach
From Reserved for future use.
Function about_Functions, about_Functions_Advanced
If about_If
In about_Foreach
Param about_Functions
Process about_Functions, about_Functions_Advanced
Return about_Return
Switch about_Switch
Throw about_Throw, about_Functions_Advanced_Methods
Trap about_Trap, about_Break, about_Try_Catch_Finally
Try about_Try_Catch_Finally
Until about_Do
While about_While, about_Do
答案 1 :(得分:0)
此外,您还可以使用Get-Alias查看所有当前保留的别名。