PSInstall.psm1

function Install-Software {
    [CmdletBinding()]
    param (
        [string]$DownloadToDirectory = $env:TEMP,
        [Switch]$GitHub,
        [Switch]$VSCode
    )
    
    begin {
        $VSCCfg = @'
[Setup]
Lang=english
Dir=C:\Program Files\Microsoft VS Code
Group=Visual Studio Code
NoIcons=0
Tasks=desktopicon,addcontextmenufiles,addcontextmenufolders,associatewithfiles,addtopath
'@
 
        
    }
    
    process {
        if ($GitHub.isPresent) {
            try {
                Write-Verbose "GitHub Desktop"
                $url = "https://central.github.com/deployments/desktop/desktop/latest/win32"
                [Net.ServicePointManager]::SecurityProtocol = "tls12, tls11, tls"
                Write-Verbose "Download - GitHub Desktop"            
                Invoke-WebRequest -Uri $url -OutFile $DownloadToDirectory\GitHubDesktopSetup.exe
                Write-Verbose "Instaling - GitHub Desktop"  
                Start-Process -Wait $DownloadToDirectory\GitHubDesktopSetup.exe 
            }
            catch {
                Write-Verbose "It was some problem with - GitHub Desktop"
            }
        }
        else {

        }

        if ($VSCode.isPresent) {
            [Net.ServicePointManager]::SecurityProtocol = "tls12, tls11, tls"
            try {
                Write-Verbose "Download - VSCode"   
                Invoke-WebRequest -Uri "https://go.microsoft.com/fwlink/?Linkid=852157" -OutFile "$DownloadToDirectory\VSCode.exe"
                $VSCCfg | Out-File -FilePath "$DownloadToDirectory\Config.ini"
                Write-Verbose "Instaling - VSCode"  
                Start-Process -Wait "$DownloadToDirectory\VSCode.exe" -ArgumentList "/LOADINF=$DownloadToDirectory\Config.ini /SILENT"
            }
            catch {
                Write-Verbose "It was some problem with - VSCode"
            }
        }
        else {

        }
    }
    
    end {
        
    }
}