Skip to content

Instantly share code, notes, and snippets.

@smtdev
Forked from lediur/machine-dev-setup.ps1
Created September 14, 2019 10:30
Show Gist options
  • Save smtdev/6da274d0b4921ed2012d9a64af876fc9 to your computer and use it in GitHub Desktop.
Save smtdev/6da274d0b4921ed2012d9a64af876fc9 to your computer and use it in GitHub Desktop.

Revisions

  1. @lediur lediur revised this gist Dec 22, 2017. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions machine-dev-setup.ps1
    Original file line number Diff line number Diff line change
    @@ -141,6 +141,7 @@ choco install 7zip -y
    # choco install greenshot -y # better screenshots
    # choco install carnac -y # http://carnackeys.com/ HUD for keypresses (useful for presentations)
    choco install sysinternals -y
    choco install putty.install -y

    # Languange Runtimes
    choco install nodejs -y
  2. @lediur lediur revised this gist Dec 22, 2017. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions machine-dev-setup.ps1
    Original file line number Diff line number Diff line change
    @@ -147,6 +147,12 @@ choco install nodejs -y
    choco install miniconda3 -y
    choco install jdk8 -y

    # Permanently set user paths
    [Environment]::SetEnvironmentVariable(
    "PATH",
    $env:PATH + ";C:\ProgramData\Miniconda3;C:\ProgramData\Miniconda3\Scripts",
    [System.EnvironmentVariableTarget]::User
    )

    # Applications
    choco install firefox -y
  3. @lediur lediur revised this gist Dec 22, 2017. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions machine-dev-setup.ps1
    Original file line number Diff line number Diff line change
    @@ -144,7 +144,7 @@ choco install sysinternals -y

    # Languange Runtimes
    choco install nodejs -y
    choco install miniconda -y
    choco install miniconda3 -y
    choco install jdk8 -y


    @@ -158,7 +158,7 @@ choco install sublimetext3 -y
    choco install hyper -y
    choco install yarn -y
    # choco install docker-for-windows -y # should install manually for beta bits
    choco install kubernetes-cli
    choco install kubernetes-cli -y
    # choco install beyondcompare -y
    choco install ProcExp -y
    choco install poshgit -y
  4. @lediur lediur revised this gist Dec 22, 2017. 1 changed file with 43 additions and 51 deletions.
    94 changes: 43 additions & 51 deletions profile.ps1
    Original file line number Diff line number Diff line change
    @@ -1,64 +1,56 @@

    import-module z
    Import-Module 'C:\tools\poshgit\dahlbyk-posh-git-a4faccd\src\posh-git.psd1'

    ### Prompt ###
    function global:prompt
    {
    $shortenedPath = (Get-ShortenedPromptPath (pwd).Path)
    function prompt {
    $shortenedPath = (Get-ShortenedPromptPath $((pwd).Path))

    $host.UI.RawUI.WindowTitle = ("PS " + $shortenedPath)
    $colorHostFg = [ConsoleColor]::White
    $colorLocation = [ConsoleColor]::Cyan
    $host.UI.RawUI.WindowTitle = ("PS " + $shortenedPath)
    $colorHostFg = [ConsoleColor]::White
    $colorLocation = [ConsoleColor]::Cyan

    if (Test-IsAdmin)
    {
    $colorHostBg = [ConsoleColor]::Red
    $host.UI.RawUI.WindowTitle += " (Admin)"
    }
    else
    {
    $colorHostBg = [ConsoleColor]::Blue
    }
    if (Test-IsAdmin) {
    $colorHostBg = [ConsoleColor]::Red
    $host.UI.RawUI.WindowTitle += " (Admin)"
    }
    else {
    $colorHostBg = [ConsoleColor]::Blue
    }

    $realLASTEXITCODE = $LASTEXITCODE
    $realLASTEXITCODE = $LASTEXITCODE

    # Reset color, which can be messed up by Enable-GitColors
    # $Host.UI.RawUI.ForegroundColor = $GitPromptSettings.DefaultForegroundColor
    # Reset color, which can be messed up by Enable-GitColors
    # $Host.UI.RawUI.ForegroundColor = $GitPromptSettings.DefaultForegroundColor

    Write-Host ([net.dns]::GetHostName().ToLower()) -n -f $colorHostFg -b $colorHostBg
    Write-Host ([net.dns]::GetHostName().ToLower()) -n -f $colorHostFg -b $colorHostBg

    Write-Host "" $shortenedPath -n -f $colorLocation
    Write-Host "" $shortenedPath -n -f $colorLocation

    Write-VcsStatus
    Write-VcsStatus

    $global:LASTEXITCODE = $realLASTEXITCODE
    $global:LASTEXITCODE = $realLASTEXITCODE

    if($shortenedPath.length -gt 20)
    {
    Write-Host " "
    }
    else
    {
    Write-Host " " -n
    }
    return "> "
    if ($shortenedPath.length -gt 20) {
    Write-Host " "
    }
    else {
    Write-Host " " -n
    }
    return "> "
    }

    function Get-ShortenedPromptPath([string] $path)
    {
    $loc = $path.Replace($HOME, '~')
    return $loc
    function Get-ShortenedPromptPath([string] $path) {
    $loc = $path.Replace($HOME, '~')
    return $loc
    }

    function Test-IsAdmin
    {
    try
    {
    function Test-IsAdmin {
    try {
    $identity = [Security.Principal.WindowsIdentity]::GetCurrent()
    $principal = New-Object Security.Principal.WindowsPrincipal -ArgumentList $identity
    return $principal.IsInRole( [Security.Principal.WindowsBuiltInRole]::Administrator )
    }
    catch
    {
    }
    catch {
    throw "Failed to determine if the current user has elevated privileges. The error was: '{0}'." -f $_
    }

    @@ -75,21 +67,21 @@ function Test-IsAdmin

    function Write-Centered {
    Param( [string] $message,
    [string] $fgcolor = "White")
    [string] $fgcolor = "White")
    $offsetvalue = [Math]::Round(([Console]::WindowWidth / 2) + ($message.Length / 2))
    Write-Host ("{0,$offsetvalue}" -f $message) -ForegroundColor $fgcolor
    }

    function Show-WelcomeMessage {
    Write-Centered ([net.dns]::GetHostName().ToUpper() -replace '(.)','$1 ') -fgcolor "White"
    Write-Centered ([net.dns]::GetHostName().ToUpper() -replace '(.)', '$1 ') -fgcolor "White"

    $current_date = Get-Date -Format 'D'
    $current_uptime = (get-date)-([System.Management.ManagementDateTimeconverter]::ToDateTime((Get-WmiObject win32_operatingsystem).lastbootuptime))
    $uptime_string = "Up for " + ("{0:%d}d {1:%h}h {2:%m}m {3:%s}s" -f ($current_uptime, $current_uptime, $current_uptime, $current_uptime))
    $current_date = Get-Date -Format 'D'
    $current_uptime = (get-date) - ([System.Management.ManagementDateTimeconverter]::ToDateTime((Get-WmiObject win32_operatingsystem).lastbootuptime))
    $uptime_string = "Up for " + ("{0:%d}d {1:%h}h {2:%m}m {3:%s}s" -f ($current_uptime, $current_uptime, $current_uptime, $current_uptime))

    Write-Centered ($current_date + " | " + $uptime_string) -fgcolor "DarkGray"
    Write-Host ""
    Write-Centered ($current_date + " | " + $uptime_string) -fgcolor "DarkGray"
    Write-Host ""
    }

    clear
    Show-WelcomeMessage
    Show-WelcomeMessage
  5. @lediur lediur revised this gist Dec 22, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion profile.ps1
    Original file line number Diff line number Diff line change
    @@ -22,7 +22,7 @@ function global:prompt
    $realLASTEXITCODE = $LASTEXITCODE

    # Reset color, which can be messed up by Enable-GitColors
    $Host.UI.RawUI.ForegroundColor = $GitPromptSettings.DefaultForegroundColor
    # $Host.UI.RawUI.ForegroundColor = $GitPromptSettings.DefaultForegroundColor

    Write-Host ([net.dns]::GetHostName().ToLower()) -n -f $colorHostFg -b $colorHostBg

  6. @lediur lediur revised this gist Dec 22, 2017. 2 changed files with 3 additions and 6 deletions.
    1 change: 1 addition & 0 deletions machine-dev-setup.ps1
    Original file line number Diff line number Diff line change
    @@ -175,6 +175,7 @@ if (!(test-path $profile.CurrentUserAllHosts)) {
    }

    Add-Content $profile.CurrentUserAllHosts $(Invoke-RestMethod "https://gist.github.com/lediur/6222254ed6e31fc70ff0aedee6a34bf8/raw/profile.ps1")
    Add-PoshGitToProfile -AllHosts

    Write-Host

    8 changes: 2 additions & 6 deletions profile.ps1
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,4 @@
    import-module z
    import-module posh-git

    ### Prompt ###
    function global:prompt
    @@ -46,11 +45,7 @@ function global:prompt

    function Get-ShortenedPromptPath([string] $path)
    {
    $loc = $path.Replace(($HOME + '\OneDrive'), $([char]0x221E))
    $loc = $loc.Replace(($HOME + '\onedrive'), $([char]0x221E))
    $loc = $loc.Replace(($HOME + '\SkyDrive'), $([char]0x221E))
    $loc = $loc.Replace(($HOME + '\skydrive'), $([char]0x221E))
    $loc = $loc.Replace($HOME, '~')
    $loc = $path.Replace($HOME, '~')
    return $loc
    }

    @@ -96,4 +91,5 @@ function Show-WelcomeMessage {
    Write-Host ""
    }

    clear
    Show-WelcomeMessage
  7. @lediur lediur revised this gist Dec 22, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion machine-dev-setup.ps1
    Original file line number Diff line number Diff line change
    @@ -157,7 +157,7 @@ choco install visualstudiocode -y
    choco install sublimetext3 -y
    choco install hyper -y
    choco install yarn -y
    choco install docker-for-windows -y
    # choco install docker-for-windows -y # should install manually for beta bits
    choco install kubernetes-cli
    # choco install beyondcompare -y
    choco install ProcExp -y
  8. @lediur lediur revised this gist Dec 22, 2017. 1 changed file with 6 additions and 6 deletions.
    12 changes: 6 additions & 6 deletions machine-dev-setup.ps1
    Original file line number Diff line number Diff line change
    @@ -130,16 +130,16 @@ choco install sourcecodepro -y
    choco install hackfont -y
    choco install dejavufonts -y
    choco install inconsolata -y
    choco install lato -y
    # choco install lato -y # very noisy
    choco install bitstreamverafonts -y

    # Tools/Utilities
    choco install git -y
    choco install git-credential-winstore -y
    choco install gitextensions -y
    # choco install gitextensions -y
    choco install 7zip -y
    choco install greenshot -y # better screenshots
    choco install carnac -y # http://carnackeys.com/ HUD for keypresses (useful for presentations)
    # choco install greenshot -y # better screenshots
    # choco install carnac -y # http://carnackeys.com/ HUD for keypresses (useful for presentations)
    choco install sysinternals -y

    # Languange Runtimes
    @@ -153,13 +153,13 @@ choco install firefox -y
    choco install googlechrome -y
    choco install intellijidea-community -y
    choco install visualstudiocode -y
    choco install atom -y
    # choco install atom -y
    choco install sublimetext3 -y
    choco install hyper -y
    choco install yarn -y
    choco install docker-for-windows -y
    choco install kubernetes-cli
    choco install beyondcompare -y
    # choco install beyondcompare -y
    choco install ProcExp -y
    choco install poshgit -y

  9. @lediur lediur revised this gist Dec 22, 2017. 1 changed file with 4 additions and 2 deletions.
    6 changes: 4 additions & 2 deletions machine-dev-setup.ps1
    Original file line number Diff line number Diff line change
    @@ -147,8 +147,9 @@ choco install nodejs -y
    choco install miniconda -y
    choco install jdk8 -y


    # Applications
    choco install firefox-dev -y
    choco install firefox -y
    choco install googlechrome -y
    choco install intellijidea-community -y
    choco install visualstudiocode -y
    @@ -184,4 +185,5 @@ Write-Host
    del C:\eula*.txt
    del C:\install.*
    del C:\vcredist.*
    del C:\vc_red.*
    del C:\vc_red.*
    del ~\Desktop\*
  10. @lediur lediur revised this gist Dec 22, 2017. 2 changed files with 4 additions and 20 deletions.
    6 changes: 3 additions & 3 deletions machine-dev-setup.ps1
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    # Inspired by https://gist.github.com/mivano/2b078f267d3ca1e9996c07085eb59a60
    # and
    # and personal machine setup scripts

    ######################
    # Configure Chocolatey
    @@ -166,14 +166,14 @@ choco install poshgit -y
    # Set up powershell profile
    ###########################

    Install-Module ZLocation -Scope CurrentUser
    Install-Module z -AllowClobber -Scope CurrentUser

    Write-Host "Creating custom $profile.CurrentUserAllHosts for Powershell"
    if (!(test-path $profile.CurrentUserAllHosts)) {
    New-Item -path $profile.CurrentUserAllHosts -type file -force
    }

    Add-Content $profile.CurrentUserAllHosts $(Invoke-RestMethod "FILL THIS IN")
    Add-Content $profile.CurrentUserAllHosts $(Invoke-RestMethod "https://gist.github.com/lediur/6222254ed6e31fc70ff0aedee6a34bf8/raw/profile.ps1")

    Write-Host

    18 changes: 1 addition & 17 deletions profile.ps1
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,6 @@

    import-module z
    import-module posh-git

    <#
    # Profile cosmetic settings
    #>

    ### Prompt ###
    function global:prompt
    {
    @@ -100,16 +96,4 @@ function Show-WelcomeMessage {
    Write-Host ""
    }

    function Start-Elevated
    {
    $file, [string]$arguments = $args;
    $psi = new-object System.Diagnostics.ProcessStartInfo $file;
    $psi.Arguments = $arguments;
    $psi.Verb = "runas";
    $psi.WorkingDirectory = get-location;
    [System.Diagnostics.Process]::Start($psi);
    }

    set-alias sudo Start-Elevated;

    Show-WelcomeMessage
  11. @lediur lediur created this gist Dec 22, 2017.
    187 changes: 187 additions & 0 deletions machine-dev-setup.ps1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,187 @@
    # Inspired by https://gist.github.com/mivano/2b078f267d3ca1e9996c07085eb59a60
    # and

    ######################
    # Configure Chocolatey
    ######################

    choco config set --name=cacheLocation --value=C:\ChocolateyCache

    choco feature enable --name=allowGlobalConfirmation
    choco feature enable --name=useRememberedArgumentsForUpgrades

    ##################
    # Privacy Settings
    ##################

    # Privacy: Let apps use my advertising ID: Disable
    Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Name Enabled -Type DWord -Value 0
    # To Restore:
    #Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Name Enabled -Type DWord -Value 1

    # Privacy: SmartScreen Filter for Store Apps: Disable
    #Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppHost -Name EnableWebContentEvaluation -Type DWord -Value 0
    # To Restore (enable):
    Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppHost -Name EnableWebContentEvaluation -Type DWord -Value 1

    # WiFi Sense: HotSpot Sharing: Disable
    # Set-ItemProperty -Path HKLM:\Software\Microsoft\PolicyManager\default\WiFi\AllowWiFiHotSpotReporting -Name value -Type DWord -Value 0
    # WiFi Sense: Shared HotSpot Auto-Connect: Disable
    Set-ItemProperty -Path HKLM:\Software\Microsoft\PolicyManager\default\WiFi\AllowAutoConnectToWiFiSenseHotspots -Name value -Type DWord -Value 0

    # Disable Telemetry (requires a reboot to take effect)
    # Set-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name AllowTelemetry -Type DWord -Value 0
    # Get-Service DiagTrack,Dmwappushservice | Stop-Service | Set-Service -StartupType Disabled

    ############################
    # Personal Preferences on UI
    ############################

    Set-WindowsExplorerOptions `
    -EnableShowHiddenFilesFoldersDrives `
    -EnableShowFileExtensions `
    -DisableOpenFileExplorerToQuickAccess `
    -DisableShowRecentFilesInQuickAccess `
    -DisableShowFrequentFoldersInQuickAccess

    Set-TaskbarOptions `
    -Dock Bottom `
    -Combine Always `
    -AlwaysShowIconsOff `
    -Size Large
    Set-TaskbarOptions -Lock

    Update-ExecutionPolicy RemoteSigned

    ###############################
    # Windows 10 Metro App Removals
    # These start commented out so you choose
    # Just remove the # (comment in PowerShell) on the ones you want to remove
    ###############################

    # Be gone, heathen!
    Get-AppxPackage king.com.CandyCrushSaga | Remove-AppxPackage
    # Bing Weather, News, Sports, and Finance (Money):
    # Get-AppxPackage Microsoft.BingWeather | Remove-AppxPackage
    Get-AppxPackage Microsoft.BingNews | Remove-AppxPackage
    Get-AppxPackage Microsoft.BingSports | Remove-AppxPackage
    Get-AppxPackage Microsoft.BingFinance | Remove-AppxPackage
    # Xbox:
    # Get-AppxPackage Microsoft.XboxApp | Remove-AppxPackage
    # Windows Phone Companion
    Get-AppxPackage Microsoft.WindowsPhone | Remove-AppxPackage
    # Solitaire Collection
    Get-AppxPackage Microsoft.MicrosoftSolitaireCollection | Remove-AppxPackage
    # People
    # Get-AppxPackage Microsoft.People | Remove-AppxPackage
    # Groove Music
    # Get-AppxPackage Microsoft.ZuneMusic | Remove-AppxPackage
    # Movies & TV
    #Get-AppxPackage Microsoft.ZuneVideo | Remove-AppxPackage
    # OneNote
    #Get-AppxPackage Microsoft.Office.OneNote | Remove-AppxPackage
    # Photos
    #Get-AppxPackage Microsoft.Windows.Photos | Remove-AppxPackage
    # Sound Recorder
    #Get-AppxPackage Microsoft.WindowsSoundRecorder | Remove-AppxPackage
    # Mail & Calendar
    #Get-AppxPackage microsoft.windowscommunicationsapps | Remove-AppxPackage
    # Skype (Metro version)
    #Get-AppxPackage Microsoft.SkypeApp | Remove-AppxPackage


    ##################
    # Windows Features
    ##################

    choco install Microsoft-Hyper-V-All --source windowsfeatures
    choco install Microsoft-Windows-Subsystem-Linux --source windowsfeatures


    #################
    # Windows Updates
    #################

    # Change Windows Updates to "Notify to schedule restart"
    # Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings -Name UxOption -Type DWord -Value 1
    # To Restore (Automatic):
    # Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings -Name UxOption -Type DWord -Value 0

    # Disable P2P Update downlods outside of local network
    # Set-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config -Name DODownloadMode -Type DWord -Value 1
    # Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization -Name SystemSettingsDownloadMode -Type DWord -Value 3

    # To restore (PCs on my local network and PCs on the internet)
    # Set-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config -Name DODownloadMode -Type DWord -Value 3
    # Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization -Name SystemSettingsDownloadMode -Type DWord -Value 1

    # To disable P2P update downloads completely:
    # Set-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config -Name DODownloadMode -Type DWord -Value 0

    Install-WindowsUpdate -AcceptEula -GetUpdatesFromMS

    ##################
    # Install packages
    ##################

    # Typefaces
    choco install firacode -y
    choco install sourcecodepro -y
    choco install hackfont -y
    choco install dejavufonts -y
    choco install inconsolata -y
    choco install lato -y
    choco install bitstreamverafonts -y

    # Tools/Utilities
    choco install git -y
    choco install git-credential-winstore -y
    choco install gitextensions -y
    choco install 7zip -y
    choco install greenshot -y # better screenshots
    choco install carnac -y # http://carnackeys.com/ HUD for keypresses (useful for presentations)
    choco install sysinternals -y

    # Languange Runtimes
    choco install nodejs -y
    choco install miniconda -y
    choco install jdk8 -y

    # Applications
    choco install firefox-dev -y
    choco install googlechrome -y
    choco install intellijidea-community -y
    choco install visualstudiocode -y
    choco install atom -y
    choco install sublimetext3 -y
    choco install hyper -y
    choco install yarn -y
    choco install docker-for-windows -y
    choco install kubernetes-cli
    choco install beyondcompare -y
    choco install ProcExp -y
    choco install poshgit -y

    ###########################
    # Set up powershell profile
    ###########################

    Install-Module ZLocation -Scope CurrentUser

    Write-Host "Creating custom $profile.CurrentUserAllHosts for Powershell"
    if (!(test-path $profile.CurrentUserAllHosts)) {
    New-Item -path $profile.CurrentUserAllHosts -type file -force
    }

    Add-Content $profile.CurrentUserAllHosts $(Invoke-RestMethod "FILL THIS IN")

    Write-Host

    #########
    # Cleanup
    #########

    del C:\eula*.txt
    del C:\install.*
    del C:\vcredist.*
    del C:\vc_red.*
    115 changes: 115 additions & 0 deletions profile.ps1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,115 @@

    import-module posh-git

    <#
    # Profile cosmetic settings
    #>

    ### Prompt ###
    function global:prompt
    {
    $shortenedPath = (Get-ShortenedPromptPath (pwd).Path)

    $host.UI.RawUI.WindowTitle = ("PS " + $shortenedPath)
    $colorHostFg = [ConsoleColor]::White
    $colorLocation = [ConsoleColor]::Cyan

    if (Test-IsAdmin)
    {
    $colorHostBg = [ConsoleColor]::Red
    $host.UI.RawUI.WindowTitle += " (Admin)"
    }
    else
    {
    $colorHostBg = [ConsoleColor]::Blue
    }

    $realLASTEXITCODE = $LASTEXITCODE

    # Reset color, which can be messed up by Enable-GitColors
    $Host.UI.RawUI.ForegroundColor = $GitPromptSettings.DefaultForegroundColor

    Write-Host ([net.dns]::GetHostName().ToLower()) -n -f $colorHostFg -b $colorHostBg

    Write-Host "" $shortenedPath -n -f $colorLocation

    Write-VcsStatus

    $global:LASTEXITCODE = $realLASTEXITCODE

    if($shortenedPath.length -gt 20)
    {
    Write-Host " "
    }
    else
    {
    Write-Host " " -n
    }
    return "> "
    }

    function Get-ShortenedPromptPath([string] $path)
    {
    $loc = $path.Replace(($HOME + '\OneDrive'), $([char]0x221E))
    $loc = $loc.Replace(($HOME + '\onedrive'), $([char]0x221E))
    $loc = $loc.Replace(($HOME + '\SkyDrive'), $([char]0x221E))
    $loc = $loc.Replace(($HOME + '\skydrive'), $([char]0x221E))
    $loc = $loc.Replace($HOME, '~')
    return $loc
    }

    function Test-IsAdmin
    {
    try
    {
    $identity = [Security.Principal.WindowsIdentity]::GetCurrent()
    $principal = New-Object Security.Principal.WindowsPrincipal -ArgumentList $identity
    return $principal.IsInRole( [Security.Principal.WindowsBuiltInRole]::Administrator )
    }
    catch
    {
    throw "Failed to determine if the current user has elevated privileges. The error was: '{0}'." -f $_
    }

    <#
    .SYNOPSIS
    Checks if the current Powershell instance is running with elevated privileges or not.
    .EXAMPLE
    PS C:\> Test-IsAdmin
    .OUTPUTS
    System.Boolean
    True if the current Powershell is elevated, false if not.
    #>
    }

    function Write-Centered {
    Param( [string] $message,
    [string] $fgcolor = "White")
    $offsetvalue = [Math]::Round(([Console]::WindowWidth / 2) + ($message.Length / 2))
    Write-Host ("{0,$offsetvalue}" -f $message) -ForegroundColor $fgcolor
    }

    function Show-WelcomeMessage {
    Write-Centered ([net.dns]::GetHostName().ToUpper() -replace '(.)','$1 ') -fgcolor "White"

    $current_date = Get-Date -Format 'D'
    $current_uptime = (get-date)-([System.Management.ManagementDateTimeconverter]::ToDateTime((Get-WmiObject win32_operatingsystem).lastbootuptime))
    $uptime_string = "Up for " + ("{0:%d}d {1:%h}h {2:%m}m {3:%s}s" -f ($current_uptime, $current_uptime, $current_uptime, $current_uptime))

    Write-Centered ($current_date + " | " + $uptime_string) -fgcolor "DarkGray"
    Write-Host ""
    }

    function Start-Elevated
    {
    $file, [string]$arguments = $args;
    $psi = new-object System.Diagnostics.ProcessStartInfo $file;
    $psi.Arguments = $arguments;
    $psi.Verb = "runas";
    $psi.WorkingDirectory = get-location;
    [System.Diagnostics.Process]::Start($psi);
    }

    set-alias sudo Start-Elevated;

    Show-WelcomeMessage