PowerShell and Strings

Here is a memento of several ways to play with strings in PowerShell.

  • Insert Double Quote and ASCII codes
  • Return a specified number of characters

 

Insert Double Quotes and ASCII Codes

To insert double quotes in a string, the following ASCII code can be used: [char]34

ASCII codes can be inserted like follow: $([char]34)

For example, using the UserName environment variable:

.

 

Return a specified number of characters in a string

Here is the equivalent function of the VBS function “MID