• Recent
  • Popular
  • Unsolved
  • Categories
  • Tags
  • Chat
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
SysAdmins Zone Logo

Query URLs

Scheduled Pinned Locked Moved Scripts
1 Posts 1 Posters 16 Views
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • katosK Offline
    katosK Offline
    katos Admin
    wrote on last edited by tankerkiller125
    #1

    Hi guys!
    This script queries shorturl's to attempt to obtain the real address. This is useful for attempting to determining the actual website when a short URL is sent. For example, we use this at work to attempt to determine the final URL before viewing the site within the helpdesk, useful to prevent us landing on a potentially malicious site.

    function Resolve-ShortURL {
        <#
    .SYNOPSIS
        Function to resolve a short URL to the absolute URI - useful for spam / malicious site checking.
    .DESCRIPTION
        Function to resolve a short URL to the absolute URI
    .PARAMETER ShortUrl
        Specifies the ShortURL
    .EXAMPLE
        Resolve-ShortURL -ShortUrl https://bit.ly/2MRHUiE
    .EXAMPLE
        Resolve-ShortURL -ShortUrl https://bit.ly/2MRHUiE
    #>
    
        [CmdletBinding()]
        [OutputType([System.String])]
        PARAM
        (
            [String[]]$ShortUrl
        )
    
        FOREACH ($URL in $ShortUrl) {
            TRY {
                Write-Verbose -Message "$URL - Querying..."
                (Invoke-WebRequest -Uri $URL -MaximumRedirection 0 -ErrorAction Ignore).Headers.Location
            }
            CATCH {
                $PSCmdlet.ThrowTerminatingError($_)
            }
        }
    }
    
    1 Reply Last reply
    0

© Copyright 2023, SysAdmins Zone.
Terms of Service | Privacy Policy
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Recent
  • Popular
  • Unsolved
  • Categories
  • Tags
  • Chat
  • Login

  • Don't have an account? Register

  • Login or register to search.