mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-08-09 13:04:59 +02:00
Updated the Markdown manuals
This commit is contained in:
65
docs/write-powershell-profile.md
Normal file
65
docs/write-powershell-profile.md
Normal file
@ -0,0 +1,65 @@
|
||||
*write-powershell-profile.ps1*
|
||||
================
|
||||
|
||||
This PowerShell script writes the PowerShell profile for the current user.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
```powershell
|
||||
PS> ./write-powershell-profile.ps1 [<CommonParameters>]
|
||||
|
||||
[<CommonParameters>]
|
||||
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
|
||||
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
|
||||
```
|
||||
|
||||
Example
|
||||
-------
|
||||
```powershell
|
||||
PS> ./write-powershell-profile.ps1
|
||||
|
||||
```
|
||||
|
||||
Notes
|
||||
-----
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
|
||||
Related Links
|
||||
-------------
|
||||
https://github.com/fleschutz/PowerShell
|
||||
|
||||
Script Content
|
||||
--------------
|
||||
```powershell
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Writes the user's PowerShell profile
|
||||
.DESCRIPTION
|
||||
This PowerShell script writes the PowerShell profile for the current user.
|
||||
.EXAMPLE
|
||||
PS> ./write-powershell-profile.ps1
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
try {
|
||||
"⏳ (1/3) Querying path to PowerShell profile 'CurrentUserCurrentHost'..."
|
||||
$pathToProfile = $PROFILE.CurrentUserCurrentHost
|
||||
|
||||
"⏳ (2/3) Creating the profile (if non-existent)..."
|
||||
$null = New-Item -Path $pathToProfile -ItemType "file" -Force
|
||||
|
||||
"⏳ (3/3) Updating the profile by my-profile.ps1..."
|
||||
Copy-Item "$PSScriptRoot/my-profile.ps1" "$pathToProfile" -force
|
||||
|
||||
"✔️ Updated your PowerShell profile - it gets active on next login"
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
```
|
||||
|
||||
*(generated by convert-ps2md.ps1 using the comment-based help of write-powershell-profile.ps1 as of 01/03/2024 12:10:53)*
|
Reference in New Issue
Block a user