Skip to content

Instantly share code, notes, and snippets.

@eugrus
Created November 8, 2023 10:36
Show Gist options
  • Save eugrus/347dbe683d9d20f339dc30c6e43d4972 to your computer and use it in GitHub Desktop.
Save eugrus/347dbe683d9d20f339dc30c6e43d4972 to your computer and use it in GitHub Desktop.
param(
[string]$path = "."
)
function Get-FolderStructure {
param(
[string]$folderPath
)
$folders = Get-ChildItem -Path $folderPath -Directory
foreach ($folder in $folders) {
Write-Output "Folder: $($folder.FullName)"
$files = Get-ChildItem -Path $folder.FullName
foreach ($file in $files) {
if ($file.Extension -eq ".lnk") {
$shortcut = (New-Object -ComObject WScript.Shell).CreateShortcut($file.FullName)
$targetPath = $shortcut.TargetPath
Write-Output " Shortcut: $($file.Name) -> $($targetPath)"
}
}
Get-FolderStructure -folderPath $folder.FullName
}
}
Get-FolderStructure -folderPath $path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment