小编Dan*_*örk的帖子

如何从文本(NVARCHAR(MAX))列中提取一个或多个URL

我的表中有一个数据列,在此列中,每行上可以有零个,一个或多个URL,以及其他文本。我想将这些URL提取到仅包含这些URL的新数据集中。

为什么?因为我想将其中一些URL添加到数据库中的阻止列表中,以防止出现垃圾邮件。

例如,我在数据列中有以下文本:

hmaruqbtufcvdlfu, <a href="httx://portugal-forex.com/">Day forex signal strategy trading</a>, KzxiIIO, [url=httx://portugal-forex.com/]Forex Broker[/url], mtNZQDi, httx://portugal-forex.com/ The best forex broker, IBWlBzg, <a href="httx://phen375treatment.com/">Avantage inconveniant phen 375</a>, ApEuXTp, [url=httx://phen375treatment.com/]Phen375[/url], QDVLpSn, httx://phen375treatment.com/ Where to buy phen 375, Fnwpugj, <a href="httx://priligy2000.org/">Priligy t</a>, zwRZhIC, [url=httx://priligy2000.org/]Order priligy[/url], FBgSaWs, httx://priligy2000.org/ Priligy buy online, FsemWnW, <a href="httx://ossorio.org/">Online Casino</a>, aOBtTaK, [url=httx://ossorio.org/]Online Casino[/url], oMMMacf, httx://ossorio.org/ Free online casino bounuses, occFLyZ, <a href="httx://paroxetine247.com/">Paroxetine adema</a>, xvrIdnq, [url=httx://paroxetine247.com/]Paroxetine depression[/url], MLSRAXX, httx://paroxetine247.com/ Paroxetine dark skin, GLYTcZY, <a href="httx://resolvedisputes.org/">Fioricet prescription online</a>, PmEMaMA, [url=httx://resolvedisputes.org/]Fioricet wcodiene for …
Run Code Online (Sandbox Code Playgroud)

regex t-sql sql-server substring

6
推荐指数
1
解决办法
2394
查看次数

使用 powershell 将多个 CIDR 添加到 SourceAddressPrefix 到 Azure NSG 规则

使用 powershell 在 Azure 中创建 NSG 规则时,我尝试将多个 CIDR 添加到 SourceAddressPrefix。我在运行 Set-AzNetworkSecurityGroup 时收到错误消息,因此它在使用 New-AzNetworkSecurityRuleConfig 创建规则时接受该值。有人知道如何解决吗?注意:是的,我知道我可以创建多个规则,但我想尽可能避免这种情况。

使用门户可以正常工作,但使用 Powershell 时会收到错误消息。

尝试1:

 $rule3 = New-AzNetworkSecurityRuleConfig -Name "In-SandNet-Vnet-Any-Any" `
-Access Allow -Protocol *  -Direction Inbound -Priority 1000 -SourceAddressPrefix {"10.0.0.0/8","192.168.0.0/16"} `
 -SourcePortRange * -DestinationAddressPrefix VirtualNetwork  -DestinationPortRange * 

$nsg.SecurityRules.Add($rule3)

Set-AzNetworkSecurityGroup -NetworkSecurityGroup $nsg
Run Code Online (Sandbox Code Playgroud)

错误信息:

xxx has invalid Address prefix. Value provided: "10.0.0.0/8","192.168.0.0/16"
Run Code Online (Sandbox Code Playgroud)

尝试2:

$rule3 = New-AzNetworkSecurityRuleConfig -Name "In-SandNet-Vnet-Any-Any" `
    -Access Allow -Protocol *  -Direction Inbound -Priority 1000 -SourceAddressPrefix "10.0.0.0/8,192.168.0.0/16" `
     -SourcePortRange * -DestinationAddressPrefix VirtualNetwork  -DestinationPortRange * 

$nsg.SecurityRules.Add($rule3)


Set-AzNetworkSecurityGroup …
Run Code Online (Sandbox Code Playgroud)

powershell azure azure-nsg

2
推荐指数
1
解决办法
1502
查看次数

如何使用powershell转换文件内容

我有一个奇怪格式的日志文件,我想将其转换为表格。格式是每行包含多个键值对(每行相同对)。我想转换这些行,以便每个属性成为包含行中值的表中的一列。

请注意,原始日志文件每行包含 39 个属性,日志文件大约为 80MB。

示例行:

date=2019-12-02 srcip=8.8.8.8 destip=8.8.4.4 srcintf="port2"
date=2019-12-01 srcip=8.8.8.8 destip=8.8.4.4 srcintf="xyz abc"
date=2019-12-03 srcip=8.8.8.8 destip=8.8.4.4 srcintf="port2"
date=2019-12-05 srcip=8.8.8.8 destip=8.8.4.4 srcintf="port2"
date=2019-12-07 srcip=8.8.8.8 destip=8.8.4.4 srcintf="port2"
Run Code Online (Sandbox Code Playgroud)

我试过了:

Get-Content .\testfile.log | select -First 10 | ConvertFrom-String | select p1, p2, p3 | ft | Format-Wide
Run Code Online (Sandbox Code Playgroud)

但这不会将属性名称分解为列名称。所以在这个例子中,我希望 P1 是 date、p2 srcip 和 p3 destip,并且每个值的第一部分被删除。

宝

任何人有任何提示或创意如何将其转换为表格?

powershell logfile

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

标签 统计

powershell ×2

azure ×1

azure-nsg ×1

logfile ×1

regex ×1

sql-server ×1

substring ×1

t-sql ×1