Webcast Recap: Using Regular Expressions in PowerShell

Brook Allred headshot
Brook Allred|June 25, 2019
Generic blog header
Generic blog header

Here's a recap of what you may have missed in our webcast last Thursday where we talked about using Regular Expressions in PowerShell.

Regular Expressions

Last week on PDQ Live we went over some of the uses for RegEx and how it can help you clean up your data for easier use in scripts.

For some RegEx resources see below or check out part of the webcast by clicking here.

Using ‘-replace’ in PowerShell to modify a string.

Using ‘-replace’ in PowerShell to modify a string.

Using Regex to standardize data for easier use in scripts.

Using Regex to standardize data for easier use in scripts.

Q&A Question 1: What's a good resource for troubleshooting PowerShell scripts and why all the things are broken with it?

What's a good resource for troubleshooting PowerShell Scripts
Using PDQ CLI to get your license expiration date

Q&A Question 2: What are some of the best formatting practices when writing functions?

In the Powershell ISE you can right click select ‘Start Snippets’ and use the pre-built snippets. These will provide templates for common functions.

question 2

Q&A Question 3: Is there a way to run a PowerShell script and have the results emailed similar to report emailing?

There is a built-in cmdlet called 'Send-MailMessage' You can use this to send the result of the script. To prevent it from sending empty emails you could compare the result of your script to $null before sending the email.

question 3

Q&A Question 4: How would you get info from AD - Like getting their phone numbers?

You can use the Get-ADUser to pull pretty much any info you need from the user object. Make sure you specify the property you want using the -Property flag.

question 4

Q&A Question 5: I am uninstalling a program with PowerShell script and PDQ Deploy, but the PowerShell script hangs. Is there a way to end the PowerShell script and move on to the next step?

It really depends on why the script is hanging. A common issue is forgetting to add the silent parameters to the uninstall string, if this happens it will pop-up a window expecting you to interact with the uninstall window. If you have a specific issue feel free to hit up support@pdq.com.

question 5
Using Regex to pull useful data from a messy source

Swag Winners

  • Anthony L.

  • Jim L.

Brook Allred headshot
Brook Allred

Brook is 100% definitely a human and enjoys human activities such as sleeping, correctly solving captchas, and eating food for energy. He's been sentient a sysadmin for ten years.

Related articles