2020-04-03 03:26:32 -04:00
|
|
|
# # Self-elevate the script if required
|
|
|
|
# if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) {
|
|
|
|
# if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) {
|
|
|
|
# $CommandLine = "-File `"" + $MyInvocation.MyCommand.Path + "`" " + $MyInvocation.UnboundArguments
|
|
|
|
# Start-Process -FilePath PowerShell.exe -Verb Runas -ArgumentList $CommandLine
|
|
|
|
# Exit
|
|
|
|
# }
|
|
|
|
# }
|
|
|
|
|
2021-07-02 09:40:29 -04:00
|
|
|
# Disable UAC
|
2021-07-02 11:09:42 -04:00
|
|
|
$uac_reg_value = Get-ItemPropertyValue -Path Registry::HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System -Name EnableLUA
|
|
|
|
|
|
|
|
if(-not $uac_reg_value -eq 0)
|
|
|
|
{
|
|
|
|
Try {
|
|
|
|
REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /t REG_DWORD /f /v "EnableLUA" /d "0"
|
|
|
|
Write-Host "UAC is now disabled."
|
|
|
|
}
|
|
|
|
Catch {
|
|
|
|
Write-Host "Error - Exception caught in disabling UAC : $error[0]"
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
Write-Host "UAC is Disabled"
|
2021-07-02 09:40:29 -04:00
|
|
|
}
|
|
|
|
|
2021-07-02 11:09:42 -04:00
|
|
|
|
2021-07-02 09:40:29 -04:00
|
|
|
# Enable Developer Mode
|
2021-07-02 11:09:42 -04:00
|
|
|
$dev_mode_alldev_reg_value = Get-ItemPropertyValue -Path Registry::HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock -Name AllowDevelopmentWithoutDevLicense
|
|
|
|
$dev_mode_allapp_reg_value = Get-ItemPropertyValue -Path Registry::HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock -Name AllowAllTrustedApps
|
|
|
|
|
|
|
|
if(-not $dev_mode_alldev_reg_value -eq 1 -or -not $dev_mode_allapp_reg_value -eq 1)
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" /t REG_DWORD /f /v "AllowDevelopmentWithoutDevLicense" /d "1" /t REG_DWORD /f /v "AllowAllTrustedApps" /d "1"
|
|
|
|
}
|
|
|
|
catch {
|
|
|
|
Write-Host "Error - Exception caught in Enabling Developer Mode: $error[0]"
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
write-Host "Developer Mode is Enabled"
|
|
|
|
}
|
2021-07-02 09:40:29 -04:00
|
|
|
|
|
|
|
# Set environmenmt variables
|
|
|
|
## CMDER_ROOT
|
2021-07-02 11:09:42 -04:00
|
|
|
if(-not $env:CMDER_ROOT)
|
|
|
|
{
|
|
|
|
[System.Environment]::SetEnvironmentVariable('CMDER_ROOT',"$($env:USERPROFILE)\Cmder", [System.EnvironmentVariableTarget]::Machine)
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
Write-Host "CMDER_ROOT=$env:CMDER_ROOT"
|
|
|
|
}
|
2021-07-02 09:40:29 -04:00
|
|
|
|
2021-07-02 09:52:42 -04:00
|
|
|
# DEV_PATH --Use this per-machine, i.e. laptops sometimes only have a single disk and desktops have multiple disks
|
2021-07-02 11:09:42 -04:00
|
|
|
if(-not $env:DEV_PATH)
|
|
|
|
{
|
|
|
|
$dev_path = Read-Host -Prompt 'Input the Repos Path:'
|
|
|
|
[System.Environment]::SetEnvironmentVariable('DEV_PATH', $dev_path, [System.EnvironmentVariableTarget]::Machine)
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
Write-Host "DEV_PATH=$env:DEV_PATH"
|
|
|
|
}
|
|
|
|
|
2021-07-02 09:52:42 -04:00
|
|
|
# NC_PATH --Use this per-machine
|
2021-07-02 11:09:42 -04:00
|
|
|
if(-not $env:NC_PATH)
|
|
|
|
{
|
|
|
|
$nc_path = Read-Host -Prompt 'Input the Nextcloud Path:'
|
|
|
|
[System.Environment]::SetEnvironmentVariable('NC_PATH', $nc_path, [System.EnvironmentVariableTarget]::Machine)
|
|
|
|
} else {
|
|
|
|
Write-Host "NC_PATH=$env:NC_PATH"
|
|
|
|
}
|
|
|
|
|
2021-07-03 07:02:42 -04:00
|
|
|
# User Profile and App Data Dirs
|
2020-04-03 03:26:32 -04:00
|
|
|
Write-Host "User Profile Directory: $($env:USERPROFILE)"
|
2021-07-03 07:02:42 -04:00
|
|
|
$local_app_data = $env:LOCALAPPDATA
|
2020-04-03 03:26:32 -04:00
|
|
|
$app_data = $env:APPDATA
|
2021-07-03 07:02:42 -04:00
|
|
|
|
|
|
|
# VS Code Directories
|
|
|
|
$vscode_installed = Test-Path -Path "$local_app_data\Programs\Microsoft VS Code\Code.exe"
|
|
|
|
if(-not $vscode_installed)
|
|
|
|
{
|
|
|
|
New-Item -ItemType Directory -Force -Path "$($app_data)\Code\User"
|
|
|
|
Write-Host "VS Code User Directory: $($app_data)\Code\User"
|
|
|
|
}
|
2021-06-20 09:54:25 -04:00
|
|
|
|
2020-04-03 03:26:32 -04:00
|
|
|
$vscode_user_settings_path = "$($app_data)\Code\User\settings.json"
|
|
|
|
Write-Host "VS Code User Settings Path: $($vscode_user_settings_path)"
|
|
|
|
|
2021-07-03 07:02:42 -04:00
|
|
|
# Cmder Config Directories
|
2021-06-20 10:41:40 -04:00
|
|
|
$cmder_root = "$($env:USERPROFILE)\Cmder"
|
2021-07-03 07:02:42 -04:00
|
|
|
$cmder_installed = Test-Path -Path "$cmder_root\Cmder.exe"
|
|
|
|
Write-Host "Cmder Installed: $cmder_installed"
|
|
|
|
|
|
|
|
# DL and Extarct Cmder Directory
|
|
|
|
if(-not $cmder_installed)
|
|
|
|
{
|
|
|
|
$cmder_version = Read-Host -Prompt 'Input Latest Cmder Release'
|
|
|
|
$cmder_url = "https://github.com/cmderdev/cmder/releases/download/$($cmder_version)/cmder_mini.zip"
|
|
|
|
$download_zip_file = "$($env:USERPROFILE)\Downloads" + $(Split-Path -Path $url -Leaf)
|
|
|
|
$extract_path = $cmder_root
|
|
|
|
Invoke-WebRequest -Uri $cmder_url -OutFile $download_zip_file
|
|
|
|
$extract_shell = New-Object -ComObject Shell.Application
|
|
|
|
$extract_files = $extract_shell.Namespace($download_zip_file).Items()
|
|
|
|
$extract_shell.Namespace($extract_path).CopyHere($extract_files)
|
|
|
|
Start-Process $extract_path
|
|
|
|
} else {
|
|
|
|
Write-Host "Cmder is installed"
|
|
|
|
}
|
|
|
|
|
|
|
|
# Ensure Cmder Dirs
|
|
|
|
if(-not $cmder_installed)
|
|
|
|
{
|
|
|
|
New-Item -ItemType Directory -Force -Path "$($cmder_root)\config"
|
|
|
|
Write-Host "Cmder Config Directory: $($cmder_root)\config"
|
|
|
|
} else {
|
|
|
|
Write-Host "Cmder Config Directory Exists"
|
|
|
|
}
|
2021-06-20 09:54:25 -04:00
|
|
|
|
|
|
|
$cmder_user_conemu_xml_path = "$($cmder_root)\config\user_ConEmu.xml"
|
|
|
|
Write-Host "Cmder ConEmu Path: $($cmder_user_conemu_xml_path)"
|
|
|
|
|
2020-04-03 03:26:32 -04:00
|
|
|
$cmder_user_profile_cmd_path = "$($cmder_root)\config\user_profile.cmd"
|
|
|
|
Write-Host "Cmder CMD User Profile Path: $($cmder_user_profile_cmd_path)"
|
2021-06-20 09:54:25 -04:00
|
|
|
|
2020-04-03 03:26:32 -04:00
|
|
|
$cmder_user_aliases_cmd_path = "$($cmder_root)\config\user_aliases.cmd"
|
|
|
|
Write-Host "Cmder CMD Aliases Path: $($cmder_user_aliases_cmd_path)"
|
2021-06-20 09:54:25 -04:00
|
|
|
|
2020-04-03 03:26:32 -04:00
|
|
|
$cmder_user_profile_ps_path = "$($cmder_root)\config\user_profile.ps1"
|
|
|
|
Write-Host "Cmder PowerShell Profile Path: $($cmder_user_profile_ps_path)"
|
|
|
|
|
2021-06-20 09:54:25 -04:00
|
|
|
# Cmder DOSKEY Aliases
|
2020-04-02 20:40:46 -04:00
|
|
|
if (-not (Test-Path -Path $cmder_user_aliases_cmd_path)) {
|
2021-06-20 09:54:25 -04:00
|
|
|
$repo_cmder_user_aliases_cmd_path = "$($PWD)\cmder\user_aliases.cmd"
|
|
|
|
Write-Host "Repo user_aliases.cmd: $($repo_cmder_user_aliases_cmd_path)"
|
|
|
|
New-Item -Path $cmder_user_aliases_cmd_path -ItemType SymbolicLink -Value $repo_cmder_user_aliases_cmd_path
|
|
|
|
Get-Item -Path $cmder_user_aliases_cmd_path
|
2020-04-02 20:40:46 -04:00
|
|
|
} else {
|
|
|
|
Write-Host "Cmder User Aliases Exists"
|
|
|
|
}
|
|
|
|
|
2021-06-20 09:54:25 -04:00
|
|
|
# Cmder CMD Profile
|
2020-04-02 20:40:46 -04:00
|
|
|
if (-not (Test-Path -Path $cmder_user_profile_cmd_path)) {
|
2021-06-20 09:54:25 -04:00
|
|
|
$repo_cmder_user_profile_cmd_path = "$($PWD)\cmder\user_aliases.cmd"
|
|
|
|
Write-Host "Repo user_profile.cmd: $($repo_cmder_user_profile_cmd_path)"
|
|
|
|
New-Item -Path $cmder_user_profile_cmd_path -ItemType SymbolicLink -Value $repo_cmder_user_profile_cmd_path
|
|
|
|
Get-Item -Path $cmder_user_profile_cmd_path
|
2020-04-02 20:40:46 -04:00
|
|
|
} else {
|
|
|
|
Write-Host "Cmder User Profile Exists"
|
|
|
|
}
|
|
|
|
|
2021-06-20 09:54:25 -04:00
|
|
|
# Cmder Powershell User Profile
|
2020-04-02 20:40:46 -04:00
|
|
|
if (-not (Test-Path -Path $cmder_user_profile_ps_path)) {
|
2021-06-20 09:54:25 -04:00
|
|
|
$repo_cmder_user_profile_ps_path = "$($PWD)\cmder\user_profile.ps1"
|
|
|
|
Write-Host "Repo user_profile.ps1: $($repo_cmder_user_profile_ps_path)"
|
|
|
|
New-Item -Path $cmder_user_profile_ps_path -ItemType SymbolicLink -Value $repo_cmder_user_profile_ps_path
|
|
|
|
Get-Item -Path $cmder_user_profile_ps_path
|
2020-04-02 20:40:46 -04:00
|
|
|
} else {
|
|
|
|
Write-Host "Cmder Powershell Profile Exists"
|
|
|
|
}
|
|
|
|
|
2021-06-20 09:54:25 -04:00
|
|
|
# Cmder ConEmu Settings
|
|
|
|
if(-not (Test-Path -Path $cmder_user_conemu_xml_path)) {
|
|
|
|
$repo_cmder_user_conemu_cml_path = "$($PWD)\cmder\user-ConEmu.xml"
|
|
|
|
Write-Host "Repo user-ConEmu.xml: $($repo_cmder_user_conemu_cml_path)"
|
|
|
|
New-Item -Path $cmder_user_conemu_xml_path -ItemType SymbolicLink -Value $repo_cmder_user_conemu_cml_path
|
|
|
|
} else {
|
|
|
|
Write-Host "Cmder ConEum User Profile Exists"
|
|
|
|
}
|
2020-04-03 03:26:32 -04:00
|
|
|
|
2021-06-20 09:54:25 -04:00
|
|
|
# VSCODE Settings
|
2020-04-02 20:40:46 -04:00
|
|
|
if (-not (Test-Path -Path $vscode_user_settings_path)) {
|
2021-06-20 09:54:25 -04:00
|
|
|
$repo_vscode_user_settings_path = "$($PWD)\vscode\settings.json)"
|
|
|
|
Write-Host "Repo VSCode User Settings: $($repo_vscode_user_settings_path)"
|
|
|
|
New-Item -Path $vscode_user_settings_path -ItemType SymbolicLink -Value $repo_vscode_user_settings_path
|
|
|
|
Get-Item -Path $vscode_user_settings_path
|
2020-04-02 20:40:46 -04:00
|
|
|
} else {
|
|
|
|
Write-Host "VS Code User Settings Exists"
|
2020-04-03 03:26:32 -04:00
|
|
|
}
|
|
|
|
|
2021-07-03 07:02:42 -04:00
|
|
|
Write-Host -NoNewline "Install Complete. Be sure to Reboot the Machine if UAC or DEV Mode was configured. Press any key to continue.."
|
2020-04-03 03:26:32 -04:00
|
|
|
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
|