Guido Oliveira
  • Home
  • Sobre
  • Contato
  • Home
  • Sobre
  • Contato
Menu
  • Home
  • Sobre
  • Contato

Baixando as Sessões do Ignite 2019 por Keyword pelo Powershell

Published by Guido Oliveira on 25/11/2019
Categories
  • Powershell
Tags
  • BITS
  • bulk download
  • download
  • download em massa
  • Ignite 2019
  • powershell
Facebook0
Twitter0
LinkedIn0
Google+0
Pinterest0

Olá pessoal,

Recentemente tivemos o Ignite 2019 e junto deles inumeras gravações das sessões foram disponibilidadas, como o volume de sessões era muito grande decidi fazer um script que faria o download da gravação e do PPT baseado em Keywords no título.

O Script pede 2 parametros, a pasta onde os arquivos irão ser armazenados e as Keywords para procurar no titulo das sessões. O Download é feito usando o serviço BITS, e depende do Powershell 5.1 para executar com sucesso.

[CmdletBinding()]
param (
    [ValidateScript({
        if( -Not ($_ | Test-Path) ){
            throw "The Folder does not exist"
        }
        if(-Not ($_ | Test-Path -PathType Container) ){
            throw "The Path argument must be a Folder. File paths are not allowed."
        }
        return $true
    })]
    [System.IO.FileInfo]$FolderPath,
    [Parameter(Mandatory=$true)]
    [array]
    $KeyWords
)
Write-Verbose -Message 'Retrieving Data from the Ignite API'
$Sessions = Invoke-RestMethod -Uri 'https://api-myignite.techcommunity.microsoft.com/api/session/all' -Method 'GET'
$SessionstoDownload = New-Object -TypeName System.Collections.ArrayList
Write-Verbose -Message 'Filtering the Sessions by the given keywords'
$Sessions.Where({
    @($PSItem.Title -Match $($KeyWords -join '|'))
}).ForEach({
    [void]$SessionstoDownload.Add($PSItem)
})

Write-Verbose -Message ('{0} Sessions were located matching the keywords' -f $SessionstoDownload.Count)
foreach($Session in $SessionstoDownload){
    Write-Verbose -Message ('Downloading session: {0} video file' -f $Session.Title)
    $FileName = '{0} - {1}' -f $Session.sessionCodeNormalized, $Session.Title
    $VideoBitsTransfer = @{
        Source = $Session.downloadVideoLink
        Destination = Join-Path -Path $FolderPath -ChildPath "$FileName.mp4"
    }
    Start-BitsTransfer @VideoBitsTransfer

    Write-Verbose -Message ('Downloading session: {0} slide deck file' -f $Session.Title)
    $PPTBitsTransfer = @{
        Source = $Session.slideDeck
        Destination = Join-Path -Path $FolderPath -ChildPath "$FileName.pptx"
    }
    Start-BitsTransfer @PPTBitsTransfer
}
Write-Verbose -Message 'Downloads completed'

Dúvidas? Sugestões? Comente!

Até a próxima!

Share
Guido Oliveira
Guido Oliveira

Related posts

05/01/2021

Removendo dispositivos órfãos do Windows com Powershell


Read more
08/06/2020

Adicionando feriados no Outlook diretamente de um website pelo Powershell


Read more
31/03/2020

Armazenando Chaves RSA(SSH) no Azure Key Vault


Read more

1 Comment

  1. Denis Basílio Denis Basílio disse:
    02/07/2020 às 6:53 PM

    up

    Responder

Deixe uma resposta Cancelar resposta

O seu endereço de e-mail não será publicado. Campos obrigatórios são marcados com *

Esse site utiliza o Akismet para reduzir spam. Aprenda como seus dados de comentários são processados.

ME SIGA:

  • youtube
  • facebook
  • twitter
  • instagram
  • github
  • linkedin
  • telegram

Busca

Prêmios

Powershell MVP
Facebook
© 2019 Guido Oliveira. All Rights Reserved.
Menu
  • Home
  • Sobre
  • Contato