Skip to content

Instantly share code, notes, and snippets.

@pohatu
Created June 6, 2014 23:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pohatu/e00c63db11fb173674c5 to your computer and use it in GitHub Desktop.
Save pohatu/e00c63db11fb173674c5 to your computer and use it in GitHub Desktop.
# This can help you detect which shortcuts from IE are internal or external
# you may want to migrate/backup/sync https://gist.github.com/pohatu but not
# something like http://secret/internal/site
# madprops to madprops for below snippet
#http://madprops.org/blog/list-your-favorites-in-powershell/
$favs = gci $env:userprofile\favorites -rec -inc *.url |
? {select-string -inp $_ -quiet "^URL=http"} |
select @{Name="Name"; Expression={[IO.Path]::GetFileNameWithoutExtension($_.FullName)}},
@{Name="URL"; Expression={get-content $_ | ? {$_ -match "^URL=http"} | % {$_.Substring(4)}}}
# With this, then pipe the .url from each of these shortcuts to resolve-dnsname, and get the Name
# Name is FQDN, basically
# Resolve-DNSName chokes on urls like http://foo/ or http://foo/myawesomepage.html
# so [URI]($_.url).Host gets the foo out of http://foo/myawesomepage.html
# and resolve-dnsname ().Name will return something like foo.mydomain.mycorp.com
# so input will be http://foo/myawesomepage.html and output will be foo.mydomain.mycorp.com
$myFavs = ($favs | % { @{Name=$_.name; FQDN=(Resolve-DnsName ([URI]($_.url)).Host).Name}})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment