-
Notifications
You must be signed in to change notification settings - Fork 0
/
Install-Scripts.ps1
68 lines (57 loc) · 2.09 KB
/
Install-Scripts.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<#
.SYNOPSIS
Installs prerequisites for scripts.
.DESCRIPTION
Installs prerequisites for scripts.
.INPUTS
None.
.OUTPUTS
None.
.EXAMPLE
PS> .\Install-Scripts
#>
# ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#Requires -Version 5.0
[CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'Medium')]
param ([Parameter()] [switch] $UpdateHelp,
[Parameter(Mandatory = $true)] [string] $ModulesPath)
Begin
{
$script = $MyInvocation.MyCommand.Name
if(-Not (Test-Path ".\$script"))
{
Write-Host "Installation must be run from the same directory as the installer script."
exit
}
if(-Not (Test-Path $ModulesPath))
{
Write-Host "'$ModulesPath' was not found."
exit
}
$Env:PSModulePath += ";$ModulesPath"
if (-Not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
Start-Process -FilePath "pwsh.exe" -ArgumentList "-File `"$PSCommandPath`"", "-ModulesPath `"$ModulesPath`"" -Verb RunAs
exit
}
}
Process
{
Add-PathToProfile -PathVariable 'Path' -Path (Get-Location).Path
Add-PathToProfile -PathVariable 'PSModulePath' -Path $ModulesPath
Add-AliasToProfile -Script 'Set-DirectoryX-Console' -Alias 'x'
Add-AliasToProfile -Script 'Set-DirectoryX-Both' -Alias 'xb'
Add-AliasToProfile -Script 'Set-DirectoryX-Child-Console' -Alias 'xc'
Add-AliasToProfile -Script 'Set-DirectoryX-Child-Both' -Alias 'xcb'
Add-AliasToProfile -Script 'Set-DirectoryX-Child-Explorer' -Alias 'xce'
Add-AliasToProfile -Script 'Set-DirectoryX-Explorer' -Alias 'xe'
Add-AliasToProfile -Script 'Set-DirectoryX-Parent-Console' -Alias 'xp'
Add-AliasToProfile -Script 'Set-DirectoryX-Parent-Both' -Alias 'xpb'
Add-AliasToProfile -Script 'Set-DirectoryX-Parent-Explorer' -Alias 'xpe'
Add-AliasToProfile -Script 'Get-eXtremeDirectoryHelpo' -Alias 'gxdh'
Add-AliasToProfile -Script 'Get-eXtremeDirectoryHelpo' -Alias 'xdhelp'
}
End
{
Format-Profile
Complete-Install
}