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

PowerShell: How to Play a Sound

$soundFile="C:\Windows\media\tada.wav"$sound = new-Object System.Media.SoundPlayer$sound.SoundLocation=$soundFile$sound.Play()

PowerShell: Quickly Start Services that were Set to Auto

Quick Liners: # Command to checkGet-WmiObject -ClassName Win32_Service -Filter "StartMode='Auto' AND State<>'Running'" | Format-Table -Auto…

Script to remove files older than X days

------------- Batch file ------------------------@echo off:: set folder pathset dump_path="E:\Shared\APP01\LOGFILES\RatingWebService2\Rating Comments\Production":: set min age of files…