Quantcast
Channel: Windows PowerShell Forum
Viewing all articles
Browse latest Browse all 2314

regular expression string+Pattern

$
0
0

Hallo,

I have a Problem with a regular Expression. I want to check if the Connection ID of a NIC is like "LAN-"&IP-Address".

I 'm confused, because

"LAN-150.200.39.120"  -match "^LAN-*" return True

"LAN-150.200.39.120"  -match \d{1,3}\.\d{1,3}\d{1,3}\.\d{1,3}$" return True

"LAN-150.200.39.120"  -match "^LAN-\d{1,3}\.\d{1,3}\d{1,3}\.\d{1,3}$" return False, BUT seems to work on the regex Tester on regexlib.com.

Has somebody a hint, how to concatenate a string and a expression together?

Background: in a SCCM (2007) OSD TS, all the Non-Used physical-NIC will be disabled, (the NIC Connection IDs for the remaining used NICs are passed as TS-Variable %OSDAdapter0Name%).

My PS command is the following:

powershell.exe -command "& {Get-WMIObject Win32_NetworkAdapter | Where-Object {($_.PhysicalAdapter -eq $true) -and ($_.NetConnectionID -notmatch '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$')} | ForEach-Object {$_.Disable()}}"

Kindly Regards

Frederic


Viewing all articles
Browse latest Browse all 2314


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>