-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstallProfileTools.ps1
26 lines (23 loc) · 1007 Bytes
/
installProfileTools.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
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
mkdir (Split-Path -Path $profile -Parent) -errorAction SilentlyContinue
echo $null >> $profile
$parentDir = $(Split-Path $profile)
$profileTools = Join-Path -Path $parentDir -ChildPath "profileTools.psm1"
function profileTools() {
echo $profileTools
}
function syncPowershellUtils() {
mkdir -p (Split-Path -Path $profile -Parent) -errorAction SilentlyContinue
$date = $(Get-Date).ToString()
$newProfileContent = $(Invoke-WebRequest https://raw.githubusercontent.com/barnuri/powershell-utils/master/profileTools.psm1?noCache=$date).Content
echo $newProfileContent > $profileTools
$installString = "### load profileTools.psm1"
$importModuleExists = Select-String -Quiet -Pattern $installString -Path $profile
if (-not $importModuleExists)
{
echo $installString >> $profile
echo "Import-Module $profileTools -Force" >> $profile
}
Import-Module $profileTools -Force
}
syncPowershellUtils