install.ps1

########################################################################################
#
# Devdeer.Azure Installation Script
#
# --------------------------------------------------------------------------------------
#
# DEVDEER GmbH
# Alexander Schmidt
#
# --------------------------------------------------------------------------------------
#
# Copies the module to the correct location and imports it showing the result
#
########################################################################################

$platform = [System.Environment]::OSVersion.Platform
$sep = ';'
if ($platform -contains 'unix') {
    $sep = ':'
}
$dir = $env:PSModulePath -split $sep
$target = [System.Io.Path]::Combine($dir[0], "Devdeer.Azure")
$target
if (![System.IO.Directory]::Exists($target)) {
    [System.IO.Directory]::CreateDirectory($target)    
}
$isInstalled = Get-Module | Where-Object { $_.Name -eq 'Devdeer.Azure' } | Measure-Object | % { $_.Count }
if ($isInstalled -gt 0) {    
    Remove-Module Devdeer.Azure
    Write-Host "Removed previous install"  -ForegroundColor Cyan
}
Get-ChildItem $target | Remove-Item
& $PSScriptRoot\pack.ps1
Write-Host "Packing finished." -ForegroundColor Cyan
copy $PSScriptRoot\Devdeer.Azure.psm1 $target
copy $PSScriptRoot\Devdeer.Azure.psd1 $target
Write-Host "Installation..." -NoNewline
Import-Module $target\Devdeer.Azure.psd1
Write-Host "Done" -ForegroundColor Green
Get-Module | Where-Object { $_.Name -eq 'Devdeer.Azure' }
Write-Host ""
Write-Host "Module location: $target" -ForegroundColor Green