D3v*_*r0n 6 profile powershell settings
我很好奇其他Powershell开发人员在其Powershell配置文件中发现有用的内容.可能性是无止境.
例如,我经常使用的最强大的Powershell配置文件函数是我的findTextInWorkspace函数.我工作的其他开发人员现在开始使用它,因为它被证明非常方便.该函数允许我搜索我的所有本地Powershell脚本以获取特定的文本模式,例如GREP.当脚本在我们的构建服务器上失败时,我可以插入关键字来追踪罪魁祸首.由于我们的应用程序域中有许多重复的脚本和嵌套的文件夹结构,因此该功能可以让我快速找到任何有问题或行为不当的脚本的完整路径.
# find explicit text in all Workspace powershell scripts
function findTextInWorkspace ([string] $text, [string] $path = "C:\Workspace\*")
{
dir $path -recurse -filter '*.ps*1' | Get-ChildItem | select-string -pattern $text | Select-Object Path -Unique
}
Run Code Online (Sandbox Code Playgroud)
然后我可以调用它,就像这样:
cd C:\Workspace\MyApplication
findTextInWorkspace "thisvariablecausedmybuildtocrash" .
Run Code Online (Sandbox Code Playgroud)
我的问题是对于Powershell大师......你在Powershell简介中看到或使用过的最强大的"作弊"或强化是什么?我正在寻找创造性和有用的答案.
| 归档时间: |
|
| 查看次数: |
464 次 |
| 最近记录: |