This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Convert-BHGraph | |
{ | |
<# | |
.SYNOPSIS | |
Convert BloodHound graph files into CSV files. | |
.DESCRIPTION | |
The PowerShell script Convert-BHGraph is designed to convert JSON files, specifically formatted as BloodHound graph exports, into CSV files. It accepts optional parameters for the source JSON file path and the destination CSV file path, defaulting to .\bh-graph.json and .\bh-graph.csv respectively. The script reads the JSON file, extracts nodes and edges data, and constructs a hashtable for nodes to facilitate quick lookups. It then processes the edges to create custom objects representing relationships, which include labels and kinds for both source and target nodes, as well as the type of edge. Finally, these relationship objects are exported to a CSV file at the specified destination path, providing a structured representation of the graph's relationships. | |
.EXAMPLE | |
Convert-BHGraph | |
Converts the file bh-graph.json from the current directory into a CSV file named bh-g |