Posted On July 18, 2019

PowerShell: Use Regex to Select IPv4 Patterns

kimconnect 0 comments
blog.KimConnect.com >> Codes >> PowerShell: Use Regex to Select IPv4 Patterns
# This example shows how to obtain ip address of the $env:logonserver
$logonServerIP=nltest /DSGETDC:
$regexIP = [regex] "\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b"
$regexIP.Matches($logonServerIP).Value

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

Linux: Use Lubuntu 20.04, TightVNC Server, NoVNC, WebSockify to Create a Terminal Server Accessible via Any Browser!

Use Case:Imagine a virtual classroom with students using Chromebooks, iPads, and other types of computers,…

How To Add JavaScript Functions into WordPress

Assuming that the 'Code Snippets' plugin has already been installed, here's a demonstration of adding…

How To Stop, Start, Restart a Windows Service Being Stuck in ‘Stopping’ Status

Convenient Function:(related to https://blog.kimconnect.com/powershell-kill-a-windows-service-forcefully) # forceRestartService.ps1 # version 0.0.2 $serviceName='Spooler' function forceRestartService($serviceName='Spooler'){ $processId=Get-WmiObject -Class Win32_Service…