Last updated on

PowerShell is my preferred shell in windows. Even if its not as famous as bash or zsh, powershell is useful enough. So, here are my notes.

What is ... syntax?

You will probably need this short notes

And read this other doc about operators (arithmetic, assignment, logical, &, ., etc.)

Create hard links

Hard links are some of the most useful features I found in an OS. To create a single file hard link

New-Item -ItemType HardLink -Path "link" -Target "target"

our process starts in the link file and ends at the target destination. Keep in mind that the link must not exist at the moment of creating the hard link.

For a folder link:

New-Item -ItemType Junction -Path "link" -Target "target"

link and target behave the same.

note that if you want to replace $PROFILE you need to type the folder, not the ENV variable, for example:

New-Item -ItemType HardLink -Path C:\Users\aucac\Documents\PowerShell\Microsoft.PowerShell_profile.ps1 -Target <Your personal folder>/PowerShell_profile.ps1

source: this post

Can I refresh the shell without quitting the window?



How to append text from stdin to a file with PS?

You echo "pnpm-lock.yaml" | Out-File Output_file.txt -Append with the append flag.

You can list

The verbs with Get-Verb

The aliases with Get-Alias

or get help with

# or

some errors I came across and solved

Update-Help: Failed to update Help for the module(s) 'ConfigDefenderPerformance' with UI culture(s) {en-US} : One or more errors occurred. (Response status code does not indicate success: 404 (Not Found).).
English-US help content is available and can be installed using: Update-Help -UICulture en-US.

This is because Update-Help updates both PowerShell 5 and 7 and looks for the modules in a case-sensitive way. I couldn’t solve the error, but at least I found something more verbose to run:

Update-Help -Verbose -Force -ErrorAction Continue

source: StackOverflow

This post comes from github, view it here