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: Play with Time

1. Constructor: $timer=[System.Diagnostics.Stopwatch]::StartNew() 2. Accessing a property $totalSeconds=$timer.Elapsed.TotalSeconds 3. Output Time (Usage): $hours=[math]::round($totalSeconds/3600,2)write-host "It has…

How to Convert Windows Application to Run as a Service

Pre-requisites: srvany.exe (from rktools) instsrv.exe Copy srvany.exe and instsrv.exe from to c:\windows\system32 >> Run: CMD…

PowerShell: Disable Microsoft Dynamics CRM Organization

# disableCrmOrganization.ps1 $orgname='testOrg' $domain='kimconnect.com' $dnsServer='10.10.10.10' $credentials=@{ 'kimconnect\crmAdmin'='password'; 'kimconnect\devAdmin'='password'; } $usernamePrefix='kimconnect\crm' $servernameSuffix='-app01' $ipDictionary=@{ 'dev01'='1.1.1.1'; 'prod01'='2.2.2.2'; }…