-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathInstall-SumoTools.ps1
More file actions
52 lines (43 loc) · 4.29 KB
/
Install-SumoTools.ps1
File metadata and controls
52 lines (43 loc) · 4.29 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
function Install-SumoTools {
[CmdletBinding()]
param()
#Script to help install/setup SumoTools
$ModulePaths = @($env:PSModulePath -split ';')
$ExpectedUserModulePath = Join-Path -Path ([Environment]::GetFolderPath('MyDocuments')) -ChildPath WindowsPowerShell\Modules
$Destination = $ModulePaths | Where-Object { $_ -eq $ExpectedUserModulePath }
if (-not $Destination) {
$Destination = $ModulePaths | Select-Object -Index 0
}
if (-not (Test-Path ($Destination + "\SumoTools\"))) {
New-Item -Path ($Destination + "\SumoTools\") -ItemType Directory -Force | Out-Null
Write-Verbose 'Downloading SumoTools Module from https://raw.githubusercontent.com/ScriptAutomate/SumoTools/master/SumoTools.psm1'
$client = (New-Object Net.WebClient)
$client.Proxy.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials
$client.DownloadFile("https://raw.githubusercontent.com/ScriptAutomate/SumoTools/master/SumoTools.psm1", $Destination + "\SumoTools\SumoTools.psm1")
Write-Verbose 'Downloading SumoTools Module Manifest from https://raw.githubusercontent.com/ScriptAutomate/SumoTools/master/SumoTools.psd1'
$client.DownloadFile("https://raw.githubusercontent.com/ScriptAutomate/SumoTools/master/SumoTools.psd1", $Destination + "\SumoTools\SumoTools.psd1")
$executionPolicy = (Get-ExecutionPolicy)
$executionRestricted = ($executionPolicy -eq "Restricted")
if ($executionRestricted) {
Write-Warning @"
Your execution policy is $executionPolicy, this means you will not be able import or use any scripts -- including modules.
To fix this, change your execution policy to something like RemoteSigned.
PS> Set-ExecutionPolicy RemoteSigned
For more information, execute:
PS> Get-Help about_execution_policies
"@
}
if (!$executionRestricted) {
# Ensure SumoTools is imported from the location it was just installed to
Import-Module -Name $Destination\SumoTools -Verbose:$False
Get-Command -Module SumoTools
}
}
""
Write-Verbose "SumoTools is installed and ready to use"
Write-Verbose @"
For more details, visit:
https://github.com/ScriptAutomate/SumoTools
"@
}
Install-SumoTools -Verbose