Windows PowerShell is a great tool and, if you are using it frequently, one of the things you might want to do is to customize the default command prompt. This is actually a quite common activity among Linux users; hence, there are many tutorials on doing that as well. In case you want to do this kind of customization to Windows PowerShell, please follow the guidance below.
The text displayed as the prompt for each line in the PowerShell is defined with Prompt() function. You are free to override this function (hence, change the command prompt) the same way you can override any other function – by defining the function in the default user profile script. The profile scripts can be defined at one of the following locations:ir-leasing.ru
You can take any (depending on the scope you want to affect) of these files (I prefer using %windir%\system32\WindowsPowerShell\v1.0\profile.ps1) and at the following text to it, you would change your PowerShell command prompt to # (hash symbol):ЛИАНЫ
The next time your launch PowerShell, it would look like this:
It is very likely, though, that you would want to make your command prompt somehow more useful instead of just showing a hash symbol. I tried few different configurations, but for now I have stick with the following function for now:
This will result into the following prompt, which includes the time, working directory as well as the number of objects in the working directory:
It is up to you what information you want it to show or what colors to use. Feel free to use the comments section to share the scripts you use in your environment.
UNIX-based shells often include the hostname and the username in the prompt as well, but I do not think there really is a point seeing this information on every line typed in PowerShell. I think a much better place for this information is the title bar of the shell and it can be achieved easily by adding the following lines to the same profile script you used for modifying the command prompt:
Once you come up with your perfect default PowerShell profile script, including all your customization, there are chances you might want to apply this to multiple computers/servers in your environment. There are multiple ways this can be done, but probably on of the easiest is by using Group Policy Preferences (assuming you have Active Directory deployed):
One thing you should keep in mind if you are doing this is that this will overwrite %windir%\System32\WindowsPowerShellv1.0\profile.ps1 if it already exist on a machine, losing all the modifications done there.