Posh-git installation

Posh-git is a set of PowerShell scripts which provide Git integration. This post describes how to install posh-git on Windows 10 Enterprise without any proxy.

The easiest way to install posh-git is using Chocolatey, which is a Machine Package Manager – tool like apt-get – but for Windows. Chocolatey can be installed based on description on project page https://chocolatey.org/ 

So in order to install Chocolatey open Command Prompt (cmd.exe) in administrative mode, paste and run the following command:

@powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString(‚https://chocolatey.org/install.ps1’))" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin

After installation is finished screen should look like this and after seeing this message restart Command Prompt in order to be able to use choco command:

chocolatey installation done - warning

After restart run ‘choco install poshgit’ command.

During installation confirm all the questions and you should see output as below:

poshgit installation

3rd install

4th screen

During installation on Windows 10 PowerShell acted like it was freezed so don’t hesitate to use enter key in order to see the progress.

When installation is finished run PowerShell as an Administrator. After loading prompt you can see error as in the picture below:

5th powershell error

In order to get rid of this message (and load correctly PowerShell profile) you must change execution policy in PS, e.g. using cmdlet Set-Executionpolicy –ExecutionPolicy Unrestricted

After PowerShell restart this error should disappear. However there is one more step to complete for posh-git to work correctly. As for day of this post creation there’s known error in Microsoft.PowerShell_profile.ps1 which causes posh-git not fully functional, so this file content should be updated. Microsoft.PowerShell_profile.ps1 file is placed in C:\Users\your_user_name\Documents\WindowsPowerShell folder.

Replace file content with the following:

# Load posh-git example profile
. ‚C:\tools\poshgit\dahlbyk-posh-git-fadc4dd\profile.example.ps1’

Rename-Item Function:\Prompt PoshGitPrompt -Force

function Prompt() {if(Test-Path Function:\PrePoshGitPrompt){++$global:poshScope; New-Item function:\script:Write-host -value "param([object] `$object, `$backgroundColor, `$foregroundColor, [switch] `$nonewline) " -Force | Out-Null;$private:p = PrePoshGitPrompt; if(–$global:poshScope -eq 0) {Remove-Item function:\Write-Host -Force}}PoshGitPrompt}

Save file and then restart PowerShell – happy work with Git using PowerShell.

Windows Task Scheduler and PowerShell scripts

Just a quick memo:

When you run PowerShell script using Task Scheduler remember to place „exit 4” at the end of script (without quotation marks). This code means that script has run successfully.

Internet Explorer – bookmarks search

I was always wondering if there’s an option to search in Internet Explorer bookmarks. Recently I’ve found the following answer: open windows explorer and in current folder path just enter „shell:favorites” – then in search box you can enter any phrase in order to search in your bookmarks. Quite life saver, especially if you have so many bookmars as I have 😉