Export/import AD objects (users, OUs)

HowTo, PowerShell Scrtips


PowerShell Regex To Get Value Between Quotation Marks

HowTo, PowerShell Scrtips
SOURCE: https://workingsysadmin.com/quick-tip-powershell-regex-to-get-value-between-quotation-marks/

If you’ve got a value like the following…


… that maybe came from the body of a file, was returned by some other part of a script, etc., and you just want the portions that are actually between the quotes, the quickest and easiest way to get it is through a regular expression match.

That’s right, forget splitting or trimming or doing other weird string manipulation stuff. Just use the [regex]::matches() feature of PowerShell to get your values.

Matches takes two parameters. 1. The value to look for matches in, in this case the here-string in my $s variable, and 2. The regular expression to be used for matching. Since Matchesreturns a few items, we are making sure to just select the value for each match.

So what is that regex doing? Let’s break it down into it’s parts.

  • (?<=\”) this part is a look behind as specified by the ?<= part. In this case, whatever we are matching will come right after a quote. Doing the look behind prevents the quotation mark itself from actually being part of the matched value. Notice I have to escape the quotation mark character.
  • .+? this part basically matches as many characters as it takes to get to whatever the next part of the regex is. Look into regex lazy mode vs greedy mode.
  • (?=\”) this part is a look ahead as specified by the ?= part. We’re looking ahead for a quotation mark because whatever comes after our match is done will be a quotation mark.

So basically what we’ve got is “whatever comes after a quotation mark, and as much of that as you need until you get to another quotation mark”. Easy, right? Don’t you love regex?


HowTo, PowerShell Scrtips

Source: https://www.sconstantinou.com/powershell-special-characters/


As in every programming and scripting language, in PowerShell there are special characters that you can use to represent characters, that we are not able to find in the standard set. In this tutorials we will see those PowerShell special Characters and what is their use.

All special characters in PowerShell start with backtick ( ). You can use the special characters only within double quotes ( " " ). If they are used otherwise, they will not be interpreted to the desired one. First of all we will see the list of characters and then we will go through it to see more details for each of the special characters. The list is provided by Microsoft.

Special Characters List:

message tracking log

HowTo, PowerShell Scrtips


Add Days, Hours, and Minutes to Current Time


PowerTip: Add Days, Hours, and Minutes to Current Time

Hardware inventory [Инвентаризация PowerShell]

Collect information, HowTo

How get mother, video card, hdd, cpu, board powershell


Add current user to remote desktop group

HowTo, PowerShell Scrtips