Générer carte ps1 existant avec Graphviz
# 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
/image%2F0881799%2F20140610%2Fob_a8c7fe_logo2.jpg)
Commenter cet article