小编Mar*_*nto的帖子

从字符串中提取MAC地址和UUID

我提取包含大量文本以及MAC地址和UUID的字符串.例如:

![LOG[AA:AA:AA:AA:AA:AA, 0A0A0000-0000-0000-0000-A0A00A000000: found optional advertisement C0420054]LOG]!><time="09:07:57.573-120" date="04-19-2017" component="SMSPXE" context="" type="1" thread="2900" file="database.cpp:533"
Run Code Online (Sandbox Code Playgroud)

我想剥离输出只显示MAC地址(例如AA:AA:AA:AA:AA:AA)和UUID(例如0A0A0000-0000-0000-0000-A0A00A000000)

我不知道如何修剪输出.

这是我的脚本:

$Path = "\\AAAAAAAA\logs$"
$Text = "AA:AA:AA:AA:AA:AA"
$PathArray = @()
$Results = "C:\temp\test.txt"


# This code snippet gets all the files in $Path that end in ".txt".
Get-ChildItem $Path -Filter "*.log" |
Where-Object { $_.Attributes -ne "Directory"} |
ForEach-Object {
If (Get-Content $_.FullName | Select-String -Pattern $Text) {
$PathArray += $_.FullName
$PathArray += $_.FullName
}
}
Write-Host "Contents of ArrayPath:"
$PathArray …
Run Code Online (Sandbox Code Playgroud)

regex powershell

3
推荐指数
1
解决办法
532
查看次数

标签 统计

powershell ×1

regex ×1