简体   繁体   English

如何将应用程序 Package SID 转换为可用格式

[英]How to convert Application Package SID to usable format

I try to export full info about certain Windows Defender Firewall with following code:我尝试使用以下代码导出有关某些 Windows Defender 防火墙的完整信息:

 $rule = (Get-NetFirewallRule -DisplayName "Start")[0]
 $ApplicationFilter   = @($rule | Get-NetFirewallApplicationFilter)
 $AddressFilter       = @($rule | Get-NetFirewallAddressFilter)
 $PortFilter          = @($rule | Get-NetFirewallPortFilter)
 $SecurityFilter      = @($rule | Get-NetFirewallSecurityFilter)
 $ServiceFilter       = @($rule | Get-NetFirewallServiceFilter)
 $InterfaceFilter     = @($rule | Get-NetFirewallInterfaceFilter)
 $InterfaceTypeFilter = @($rule | Get-NetFirewallInterfaceTypeFilter)

Problem is that command $rule |问题是命令 $rule | Get-NetFirewallApplicationFilter gives answer in following form: Get-NetFirewallApplicationFilter 给出以下形式的答案:

 Program : Any
 Package : S-1-15-2-283421221-..........-..........-.........-..........-..........-..........

instead of name of package and username like in Windows Defender Firewall console.而不是 package 的名称和 Windows Defender Firewall 控制台中的用户名。

I spent a few hours on searching how to convert this special SID to usable form, but I've had no luck.我花了几个小时搜索如何将这个特殊的 SID 转换为可用的形式,但我没有运气。 I know, that the rule which has app package configured get value of 'Owner' property - this value is SID of user who owned package which SID is mentioned in我知道,配置了应用程序 package 的规则获取“所有者”属性的值 - 此值是拥有 package 的用户的 SID,其中提到了 SID

($rule | Get-NetFirewallApplicationFilter).Package 

but I still don't know how to get name of package Does anybody know how to do it?但我仍然不知道如何获取 package 的名称 有人知道该怎么做吗?

LukiD路基D

It looks like the group has the name if it's an appx program?如果是 appx 程序,该组似乎有名称? (appx is the enemy of administrators) (appx 是管理员的敌人)

$rule = (Get-NetFirewallRule -DisplayName "Start")[0]
if ($rule.group -match '@{.*') { 
  $appxname = $rule.group -replace '@{|_.*' 
}
$appxname

Microsoft.Windows.StartMenuExperienceHost

Here's 90 appx firewall rules.这是 90 条 appx 防火墙规则。 Sometimes the funny @{ } string is in the Displayname as well.有时有趣的 @{ } 字符串也在显示名称中。 An Intel program even has a unicode '®' in the title.一个 Intel 程序甚至在标题中有一个 unicode '®'。

get-netfirewallrule | % {
  if ($_.group -match '@{.*') { 
    $appxname = $_.group -replace '@{|_.*' 
    $displayname2 = $_.displayname -replace '@{|_.*' 
    $_ | select @{n='displayname2';e={$displayname2}},@{n='appxname';e={$appxname}}
  }
}

displayname2                               appxname
------------                               --------
Microsoft.Windows.ContentDeliveryManager   Microsoft.Windows.ContentDeliveryManager
Microsoft.Windows.CloudExperienceHost      Microsoft.Windows.CloudExperienceHost
Microsoft.Windows.CloudExperienceHost      Microsoft.Windows.CloudExperienceHost
Start                                      Microsoft.Windows.StartMenuExperienceHost
Work or school account                     Microsoft.AAD.BrokerPlugin
Intel® Graphics Command Center             AppUp.IntelGraphicsExperience
Windows Feature Experience Pack            MicrosoftWindows.Client.CBS
...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM