Reference command name with dashes

眉间皱痕 提交于 2019-12-05 04:33:43

Doh! I shoulda stuck with the Programmer Problem Solving Sequence and asked my co-workers before I posted to SO. Looks like I should use:

$hw = ${function:Hello-World}

As well as using $script = ${function:hello-world} there is also $script = get-content function:hello-world. '$' as a unary operator equates to using get-content (alias is gc)

To invoke the function all you need to do is to call it by its name.

PS> Hello-World
Hello world

${function:Hello-World} is the way to get the code of the function. Here's another way:

Get-Command Hello-World | Select-Object -ExpandProperty Definition
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!