CalebAlbers
6/27/2017 - 11:04 PM

Auto-installer for https://github.com/CalebAlbers/IT-Glue-API-PowerShell-Wrapper/

##copied from https://gist.github.com/darkoperator/6152630

$webclient = New-Object System.Net.WebClient
$url = "https://github.com/CalebAlbers/IT-Glue-API-PowerShell-Wrapper/archive/master.zip"
Write-Host "Downloading latest version of ITGlueAPI from $url" -ForegroundColor Cyan
$file = "$($env:TEMP)\ITGlueAPI.zip"
$webclient.DownloadFile($url,$file)
Write-Host "File saved to $file" -ForegroundColor Green
$targetondisk = "$($env:USERPROFILE)\Documents\WindowsPowerShell\Modules"
New-Item -ItemType Directory -Force -Path $targetondisk | out-null
$shell_app=new-object -com shell.application
$zip_file = $shell_app.namespace($file)
Write-Host "Uncompressing the Zip file to $($targetondisk)" -ForegroundColor Cyan
$destination = $shell_app.namespace($targetondisk)
$destination.Copyhere($zip_file.items(), 0x10)
Write-Host "Renaming folder" -ForegroundColor Cyan
New-Item $($targetondisk+"\ITGlueAPI") -type directory -Force
Copy-Item ($targetondisk+"\IT-Glue-API-PowerShell-Wrapper-master\ITGlueAPI\*") $($targetondisk+"\ITGlueAPI") -Recurse -Force
Remove-Item ($targetondisk+"\IT-Glue-API-PowerShell-Wrapper-master") -Recurse -Force
Write-Host "Module has been installed" -ForegroundColor Green
Import-Module -Name ITGlueAPI
Get-Command -Module ITGlueAPI