Alias entries can easily be defi ned
for commands and functions in the
Windows PowerShell. Since these are
valid only for the current session, you
want to save them and reload them if
required.
In PowerShell, profiles help in saving changes and personalised settings for the user so that these are automatically loaded and run at the time of start-up. This works similar to instructions in the ‘autoexec.bat’ batch fi le at the time of system start for older DOS-based systems.
Here it is possible to create a profile for each individual user which is saved in the user data folder as ‘Micrsoft. PowerShell_profi le.ps1’. But it usually functions for PowerShell if it is present in the ‘profile.ps1’ fi le in the installation folder of PowerShell.
First start PowerShell. Use ‘Test-Path profile’ to decide whether a profi le fi le already exists. If the return is ‘False’, then you must fi rst create the fi le. Use the command ‘New-Item –path profile –type fi le –force’. The necessary text fi le is then generated. In future, you can open it quickly in the editor for editing via the command ‘notepad profi le’.
Defi ne such settings, aliases and commands which you frequently want in the profi le. If you save some scripts in a particular folder, you can run the PowerShell on this folder immediately at the time of start instead of starting from the basis folder of the user profi le under Windows. For this, use a command such as ‘Set-Location G:\daten\skripte’. It is also practical to save the aliases for simpler operation. For example, if you want to request ‘notepad’ with the abbreviation ‘np’, then you can set up ‘set-alias np notepad.exe’ for that. Even the usually available functions are a part of the profi le fi le.
NOTE: Using personalised aliases is practical but must be avoided in a saved script as far as possible since it may then not be executable on another computer.
In PowerShell, profiles help in saving changes and personalised settings for the user so that these are automatically loaded and run at the time of start-up. This works similar to instructions in the ‘autoexec.bat’ batch fi le at the time of system start for older DOS-based systems.
Here it is possible to create a profile for each individual user which is saved in the user data folder as ‘Micrsoft. PowerShell_profi le.ps1’. But it usually functions for PowerShell if it is present in the ‘profile.ps1’ fi le in the installation folder of PowerShell.
First start PowerShell. Use ‘Test-Path profile’ to decide whether a profi le fi le already exists. If the return is ‘False’, then you must fi rst create the fi le. Use the command ‘New-Item –path profile –type fi le –force’. The necessary text fi le is then generated. In future, you can open it quickly in the editor for editing via the command ‘notepad profi le’.
Defi ne such settings, aliases and commands which you frequently want in the profi le. If you save some scripts in a particular folder, you can run the PowerShell on this folder immediately at the time of start instead of starting from the basis folder of the user profi le under Windows. For this, use a command such as ‘Set-Location G:\daten\skripte’. It is also practical to save the aliases for simpler operation. For example, if you want to request ‘notepad’ with the abbreviation ‘np’, then you can set up ‘set-alias np notepad.exe’ for that. Even the usually available functions are a part of the profi le fi le.
NOTE: Using personalised aliases is practical but must be avoided in a saved script as far as possible since it may then not be executable on another computer.
0 comments:
Post a Comment
please write your comment
Note: Only a member of this blog may post a comment.