forked from scottdware/Posh-Junos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.ps1
36 lines (27 loc) · 1.25 KB
/
install.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
$modulePath = "$($env:USERPROFILE)\Documents\WindowsPowerShell\Modules"
$poshSSH = "$($modulePath)\Posh-SSH"
$sourcePSM1 = 'https://raw.githubusercontent.com/scottdware/Posh-Junos/master/Posh-Junos.psm1'
$destination = "$($modulePath)\Posh-Junos"
$client = New-Object System.Net.WebClient
if (!(Test-Path -Path $poshSSH)) {
Write-Warning "Looks like you don't have 'Posh-SSH' installed!"
Write-Warning "Please visit https://github.com/darkoperator/Posh-SSH to install it first!"
return
}
if (Test-Path -Path $destination) {
Write-Warning "'Posh-Junos' already installed. Updating..."
Remove-Item -Force $destination -Recurse | Out-Null
Start-Sleep -Seconds 2
New-Item -Path $destination -ItemType Directory -Force | Out-Null
Start-Sleep -Seconds 1
$client.DownloadFile($sourcePSM1, "$($destination)\Posh-Junos.psm1")
Write-Host -Fore Green 'Module Posh-Junos has been successfully updated.'
}
else {
New-Item -Path $destination -ItemType Directory -Force | Out-Null
Start-Sleep -Seconds 1
$client.DownloadFile($sourcePSM1, "$($destination)\Posh-Junos.psm1")
Write-Host -Fore Green 'Module Posh-Junos has been successfully installed.'
}
Import-Module Posh-Junos
Get-Command -Module Posh-Junos