From 14cdda0298d590fe4bed0a58d4d66bdc9e2fe3af Mon Sep 17 00:00:00 2001 From: Klaus Frank Date: Tue, 26 Dec 2017 04:11:09 +0100 Subject: [PATCH 1/3] Mention PowerShell Repository Added a section about the PowerShell Gallery and how to pull and update PowerShell Modules from there. --- .../sections/powershell.asc | 27 ++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/book/A-git-in-other-environments/sections/powershell.asc b/book/A-git-in-other-environments/sections/powershell.asc index 64ca0af72..52315df36 100644 --- a/book/A-git-in-other-environments/sections/powershell.asc +++ b/book/A-git-in-other-environments/sections/powershell.asc @@ -10,12 +10,33 @@ It looks like this: .Powershell with Posh-git. image::images/posh-git.png[Powershell with Posh-git.] -Just download a Posh-Git release from (https://github.com/dahlbyk/posh-git[]), and uncompress it to the `WindowsPowershell` directory. -Then open a Powershell prompt as the administrator, and do this: +==== Installation +===== Prerequisites +Before you're able to run PowerShell scripts on your machine, you need to set your local ExecutionPolicy to RemoteSigned (Basically anything except Undefined and Restricted). If you choose AllSigned instead of RemoteSigned, also local scripts (your own) need to be digitally signed in order to be executed. With RemoteSigned, only Scripts having the "ZoneIdentifier" set to Internet (were downloaded from the web) need to be signed, others not. +If you're an administrator and want to set it for all Users on that machine, use "-Scope LocalMachine". +If you're a normal user, without administrative rights, you can use "-Scope CurrentUser" to set it only for you. +More about PowerShell Scopes: (https://technet.microsoft.com/de-de/library/hh847849.aspx[]) +More about PowerShell ExecutionPolicy: (https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.security/set-executionpolicy[]) +[source,powershell] +----- +> Set-ExecutionPolicy -Scope LocalMachine -ExecutionPolicy RemoteSigned -Force +----- +===== PowerShell Gallery +If you have at least PowerShell 5 or PowerShell 4 with PackageManagement installed, you can use the package manager to fetch Posh-Git for you. +More information about the requirements: (https://docs.microsoft.com/en-us/powershell/gallery/psget/get_psget_module[]) +[source,powershell] +----- +> Update-Module PowerShellGet -Force +> Install-Module Posh-Git -Scope LocalMachine +----- +If you want to install Posh-Git only for the currnet user and not globaly, use "-Scope CurrentUser" instead. + +===== From Source +Just download a Posh-Git release from (https://github.com/dahlbyk/posh-git[]), and uncompress it to the `WindowsPowershell` directory. +Then open a Powershell prompt as an administrator, and do this: [source,powershell] ----- -> Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Confirm > cd ~\Documents\WindowsPowerShell\posh-git > .\install.ps1 ----- From a17eb359f0cbf51bdf5f1e1956bd3985fbc9f2bc Mon Sep 17 00:00:00 2001 From: Klaus Frank Date: Tue, 26 Dec 2017 04:28:40 +0100 Subject: [PATCH 2/3] Add Update PowerShell Prompt section Add Update PowerShell Prompt section --- .../sections/powershell.asc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/book/A-git-in-other-environments/sections/powershell.asc b/book/A-git-in-other-environments/sections/powershell.asc index 52315df36..48679bacb 100644 --- a/book/A-git-in-other-environments/sections/powershell.asc +++ b/book/A-git-in-other-environments/sections/powershell.asc @@ -32,12 +32,20 @@ More information about the requirements: (https://docs.microsoft.com/en-us/power ----- If you want to install Posh-Git only for the currnet user and not globaly, use "-Scope CurrentUser" instead. +===== Update PowerShell Prompt +To include git information in your prompt, posh-git needs to be imported. To do this automatically, include the import statement into you $profile script. This script is executed everytime you open a new PowerShell prompt. +Keep in mind, that there are multiple $profile scripts. E. g. one for the console and a separate one for the ISE. +[source,powershell] +----- +> 'Import-Module Posh-Git' | Out-File -Append -Encoding default -FilePath $profile +----- + ===== From Source Just download a Posh-Git release from (https://github.com/dahlbyk/posh-git[]), and uncompress it to the `WindowsPowershell` directory. Then open a Powershell prompt as an administrator, and do this: [source,powershell] ----- -> cd ~\Documents\WindowsPowerShell\posh-git +> cd ~\Documents\WindowsPowerShell\Module\posh-git > .\install.ps1 ----- From 23347660a78439671be13b68e6cf8936d24af7bf Mon Sep 17 00:00:00 2001 From: Klaus Frank Date: Sat, 13 Jan 2018 22:04:27 +0100 Subject: [PATCH 3/3] Update powershell.asc Style tweak --- book/A-git-in-other-environments/sections/powershell.asc | 1 + 1 file changed, 1 insertion(+) diff --git a/book/A-git-in-other-environments/sections/powershell.asc b/book/A-git-in-other-environments/sections/powershell.asc index 48679bacb..dcc545d4d 100644 --- a/book/A-git-in-other-environments/sections/powershell.asc +++ b/book/A-git-in-other-environments/sections/powershell.asc @@ -17,6 +17,7 @@ If you're an administrator and want to set it for all Users on that machine, use If you're a normal user, without administrative rights, you can use "-Scope CurrentUser" to set it only for you. More about PowerShell Scopes: (https://technet.microsoft.com/de-de/library/hh847849.aspx[]) More about PowerShell ExecutionPolicy: (https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.security/set-executionpolicy[]) + [source,powershell] ----- > Set-ExecutionPolicy -Scope LocalMachine -ExecutionPolicy RemoteSigned -Force