powershell PowerShell:Get-NetPrefixPolicy

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了powershell PowerShell:Get-NetPrefixPolicy相关的知识,希望对你有一定的参考价值。

function Get-NetPrefixPolicy {
	$null, $null, $null, $command = netsh int ipv6 show prefixpolicies
	[regex]$regex = '\s+(?<Precedence>\S+)\s+(?<Label>\S+)\s+(?<Prefix>\S+)'

	$command = $command | ForEach-Object {
		if ( $_ -match $regex ) {
			$object = "" | Select-Object Prefix, Precedence, Label, Name
			$object.Precedence = [uint32]$matches.Precedence
			$object.Label = [uint32]$matches.Label
			$object.Prefix = [string]$matches.Prefix
			switch ($object.Prefix) {
				('::1/128') {$object.Name = [string]'localhost'}
				('::/0') {$object.Name = [string]'ipv6'}
				('2002::/16') {$object.Name = [string]'6to4'}
				('::/96') {$object.Name = [string]'ipv4compat'}
				('::ffff:0:0/96') {$object.Name = [string]'ipv4'}
				('2001::/32') {$object.Name = [string]'teredo'}
			}
			$object
		}
	}
	$command | Sort -Property Precedence
}
function Get-NetPrefixPolicy {
	$null, $null, $null, $command = netsh int ipv6 show prefixpolicies
	[regex]$regex = '\s+(?<Precedence>\S+)\s+(?<Label>\S+)\s+(?<Prefix>\S+)'

	$command = $command | ForEach-Object {
		if ( $_ -match $regex ) {
			$object = "" | Select-Object Prefix, Precedence, Label
			$object.Precedence = [uint32]$matches.Precedence
			$object.Label = [uint32]$matches.Label
			$object.Prefix = [string]$matches.Prefix
			$object
		}
	}
	$command | Sort -Property Precedence
}

以上是关于powershell PowerShell:Get-NetPrefixPolicy的主要内容,如果未能解决你的问题,请参考以下文章

powershell PowerShell:Get-Handles

powershell PowerShell:Get-MicrosoftUpdates

powershell PowerShell:Get-NetPrefixPolicy

powershell PowerShell:Get-FileHash

powershell PowerShell:Get-ComparableVersion

powershell PowerShell:Get-OSBitness