Wednesday, February 18, 2015

PowerShell - Download Images from Web

I had a requirement where I have to export user profile images from MySite 2013 and I end up writing following PowerShell script:

[Reflection.Assembly]::LoadFile( `
'C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Web.dll')`
  | out-null 

$FileName = "C:\Temp\ImagesURL.txt";
$Loc = "C:\Temp\Images\"
$ImageName = ""

$wc = New-Object System.Net.WebClient

$content = Get-Content $FileName
foreach ($line in $content)
{
    $Image = $Loc + $line.Substring($line.LastIndexOf("/") + 1)
    $url = $line
    
    Write-Host $url
    Write-Host $Image
    
    $wc.DownloadFile($url, $Image)
    
}

write-host "Finished successfully."

Knowledge Chat Bot (No Code)

Recently my customers was looking for a solution where on-field guys can search for answers related to their tasks and it was a perfect scen...