ps/Modules/Alkami.PowerShell.SDK/Public/Remove-SMSvcHostBlankSecurityIdentifiers.ps1
2023-05-30 22:51:22 -07:00

27 lines
867 B
PowerShell

function Remove-SMSvcHostBlankSecurityIdentifiers {
<#
.SYNOPSIS
Remove blank entries that should have a SID in them
#>
[CmdletBinding()]
param ()
$paths = @(
"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\SMSvcHost.exe.config"
"C:\Windows\Microsoft.NET\Framework\v4.0.30319\SMSvcHost.exe.config"
)
foreach ($path in $paths) {
$configuration = [xml](Get-Content -Path $path)
# we only need to remove the ones that are blank
$nodes = @($configuration.configuration.'system.serviceModel.activation'.'net.tcp'.allowAccounts.add).Where({[string]::IsNullOrWhiteSpace($_.securityIdentifier)})
foreach ($node in $nodes) {
# not really anything to show here since they are blank sids
$node.ParentNode.RemoveChild($node)
}
$configuration.Save($path)
}
}