Overblog Tous les blogs Top blogs Technologie & Science Tous les blogs Technologie & Science
Editer l'article Suivre ce blog Administration + Créer mon blog
MENU

Générer carte ps1 existant avec Graphviz

Publié le par damcuvelier

# Générer la carte avec Graphviz

$DotFilePath = "SCCM_Infrastructure.dot"

$ImageFilePath = "SCCM_Infrastructure.png"

dot -Tpng $DotFilePath -o $ImageFilePath

Write-Host "Carte de l'infrastructure SCCM générée : $ImageFilePath"

 

 

//////

# Analyseur de script

Install-Module -Name PSScriptAnalyzer -Force -Scope CurrentUser

 

# Chemin du script à analyser

$scriptPath = "C:\Chemin\vers\votre\script.ps1"

 

# Analyser le script et extraire la structure

$scriptStructure = Invoke-ScriptAnalyzer -Path $scriptPath -Settings $null | Select-Object -ExpandProperty ScriptContent

 

# Convertir la structure en un format compréhensible par GraphViz

$dotFormat = "digraph ScriptMap {"

$scriptStructure | ForEach-Object {

    $dependencies = $_.Dependencies | ForEach-Object {

        "[label=`"$($_.Name)`"]"

    }

    $dotFormat += "`"$($_.Name)`" -> { $dependencies }`n"

}

$dotFormat += "}"

 

# Enregistrer le résultat dans un fichier DOT

$dotFilePath = "C:\Chemin\vers\map.dot"

$dotFormat | Out-File -FilePath $dotFilePath

 

# Utiliser GraphViz pour générer la carte

# Exécutez ensuite la commande correspondante à votre système

# Par exemple, pour Windows :

# & "C:\Chemin\vers\GraphViz\bin\dot.exe" -Tpng -o "C:\Chemin\vers\map.png" "C:\Chemin\vers\map.dot"

 

 

Graphviz-ressources:

http://damcuvelier.over-blog.net/

2024/04/graphviz-ressources.html

Commenter cet article