小编Win*_*red的帖子

显示当前正在执行的功能的名称

如何检索当前在PowerShell中运行的函数的名称?这是我想要的一个例子:

Function write-FunctionName
{
write-host "The name of this function is: *SomethingGoesHereButWhat?*"
}
Run Code Online (Sandbox Code Playgroud)

然后,当我执行它时,它将显示:

>write-FunctionName

The name of this function is: write-FunctioName

>
Run Code Online (Sandbox Code Playgroud)

可以这样做吗?如果是这样的话?

powershell

19
推荐指数
1
解决办法
7445
查看次数

PowerShell中两个以上字符串的最长公共子字符串?

如何在PowerShell中的字符串数组中找到匹配的字符串:

例:

$Arr = "1 string first",
"2 string second",
"3 string third",
"4 string fourth"
Run Code Online (Sandbox Code Playgroud)

使用此示例,我希望返回:

" string "
Run Code Online (Sandbox Code Playgroud)

我想使用它来查找文件名的匹配部分,然后删除文件名的那一部分(例如从一组mp3文件中删除艺术家的名字),而不必指定应该替换文件名的哪一部分手动.

powershell

7
推荐指数
1
解决办法
1693
查看次数

标签 统计

powershell ×2