我看到了Glenn Sarti的推文,在那里他正在构建PowerShell帮助系统的图表数据库,作为演示Neo4j的方法。
@msftzachal. 正如所承诺的那样,我写了我的powershell帮助图表演示(ps峰会)作为博客帖子 //t.co/zuQzXf7ysy
—格伦萨蒂(@Glennsarti) 2017年5月7日
我以为这是og体育很酷的想法,我很奇怪我能与我做的事情 psgraph模块 在同og体育数据集上。我是拉扯的例子 格伦萨蒂的文章 因为他做得很好解释一下。
电源外壳帮助榜样
他的第og体育例子显示了我们使用的数据。
C:\> get-help get-item
NAME
Get-Item
...
RELATED LINKS
Online Version: http://go.microsof ...
Clear-Item
Copy-Item
Invoke-Item
Move-Item
...
大多数帮助项目都有这些相关链接。这将让我们映射命令彼此的关系。
解析帮助
格伦在他的帖子上有og体育脚本,它对每个模块和cmdlet散步。然后,他将其导入图表数据库。这就是我要将它带到不同的方向的地方。我在这里有og体育简化版本的脚本,它使用psgraph。
$ModuleName = 'Microsoft.PowerShell.Utility'
$graph = graph help {
$commandList = Get-Command -Module $ModuleName
foreach($command in $commandList)
{
$help = Get-Help -Name $command.name
$links = $help.relatedLinks.navigationLink.linktext | where {$_ -notmatch 'online version|http:'}
edge -From $command.name -To $links
}
}
$graph | Export-PSGraph -ShowGraph
I define a graph and walk each command. Once I pull out the related links, I call the edge
command to build an edge from the name
node to the $links
node. It is ok if $links
is an array. The edge
command handles multiple items correctly. By defining an edge between two items, the nodes get created automatically.
我一次只会绘制og体育模块,因为单个图表上的太多节点很难读取。模块之间也没有很多重叠,所以我不觉得我错过了任何东西。
得到的图表
The resulting graphs can get rather large but here is a cropped sample from the Microsoft.PowerShell.Utility
module.
整个原因我写的PSGraph就是能够非常容易地可视化这样的数据。
结束语
我想说谢谢你的想法。我希望他不介意我建造 他的文章 像这样。如果您想要有关如何安装或使用的更多信息 Psgraph.., 请检查 这个帖子 我更详细地覆盖它的地方。