What's In Your Profile - #4 - Get-GoogleLogo function

Sometimes I just need to confirm internet connectivity on a server. While it's simple enough to Test-Connection or any slew of other options, it's sometimes nice to switch it up and have a little more 'meat' to your confirmation.

Enter Get-GoogleLogo. Three guesses on what this one does!

Hope it helps someone out there!


function Get-GoogleLogo {
    $TesterImage = "https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png";
    $TesterImageDest = 'C:\users\Administrator\Desktop\GoogleTest.png';
    
    $webclient = New-Object System.Net.WebClient;
    
    try { 
        $webclient.DownloadFile($TesterImage, $TesterImageDest)
        }
    catch {
        Write-Warning "ERROR HAS OCCURRED"
        $ErrorDetect = $true;
        return "ERROR"
        }
    if (!$ErrorDetect) {
        Write-Host "File retrieved successfully";
        [String]$string = "Retrieved Google Logo Successfully at " + (Get-Date -DisplayHint DateTime)
        $string | Out-File $LogFile -Append -ea SilentlyContinue
        }
    
    
    Remove-Item $TesterImageDest -Force -ea SilentlyContinue;
    Remove-Variable -Name ErrorDetect -ea SilentlyContinue -Force
}

Comments

Popular Posts