How to disable the beep in PowerShell

This was annoying, but easily resolved.

You can easily disable this in PowerShell by running this command:

Set-PSReadlineOption -BellStyle None

However, what you probably want is to disable this every time you open up PowerShell.  Doing this is simple.  In PowerShell, type

notepad $profile

This will most likely ask you to create a file.  Create the file, and then enter the above Set-PSRReadlineOption command into the file.  Save it, and close it.  Now, new PowerShell windows that pop open won’t make that annoying beep.

You can find out more about these profiles over on MSDN.

PowerShell for Bash Users

Working with Objects

PowerShell works with objects rather than plain text.  While this might seem odd, it’s also pretty powerful.  So, if you run the ls command, it will return a bunch of objects that have fields (Members).  You can figure out what this is easily by running ls | get-member.

PS C:\Users\jason_000> ls | get-member
...
Name Property string Name {get;}
Parent Property System.IO.DirectoryInfo Parent {get;}
Root Property System.IO.DirectoryInfo Root {get;}
BaseName ScriptProperty System.Object BaseName {get=$this.Name;}
...

So, I’ve cut out a lot of information, because you get a lot of members you can work with, but you get the idea.  But what this means is if you just want all the names, you can run (ls).name.  That will return a list of just the name members of the objects that would get returned normally.

History

Get-History is history.

Last Command

$$

Scripts in Confluence are an anti-pattern

Scripts in Confluence are an anti-pattern.

If you are going to take the time to document something out, then make an effort to take the time to script it out.  Even better, add it to something like Jenkins or Rundeck.  Maybe automate it.

This is true even if you have a list of steps in your documentation.  Run step 1, then step 2, then check for this, and if it’s true, do step 3, otherwise continue to step 4.  You are literally writing the program in English.

Scripts in Confluence are an anti-pattern. It’s not documented, it’s lazy.