CI guts for App Catalog check

Greetings everyone!

If you are following in my footsteps of exposing the App Catalog web services. Here are a few tibbits that could help you keep your services exposed.

Create a CI and use the following in the detection method.

$registryPath = "HKLM:\Software\Microsoft\SMS\PORTALWEB"
$registryName = "PortalPath"
$key = Get-ItemProperty -Path $registryPath -Name $registryName
$FilePath = $key.PortalPath+"\default.aspx"
$ConfigFile = $key.PortalPath+"\web.config"
$WebConfig1 = [System.IO.File]::ReadAllText($ConfigFile)
$WSDLVisble = $WebConfig1.Contains("<!--<remove name=""Documentation"" />-->") -or $WebConfig1.Contains("<!--<remove name=""Documentation""/>-->") -or (!($WebConfig1.Contains("<remove name=""Documentation"" />")))


Remediation (if you choose to be so brave).

$registryPath = "HKLM:\Software\Microsoft\SMS\PORTALWEB"
$registryName = "PortalPath"
$key = Get-ItemProperty -Path $registryPath -Name $registryName
$FilePath = $key.PortalPath+"\default.aspx"
$ConfigFile = $key.PortalPath+"\web.config"
$WebConfig1 = [System.IO.File]::ReadAllText($ConfigFile)
If (!($WebConfig1.Contains("<!--<remove name=""Documentation""/>-->")))
{
$WebConfig1 = $WebConfig1.Replace("<remove name=""Documentation"" />","<!--<remove name=""Documentation"" />-->")
[System.IO.File]::WriteAllText($ConfigFile, $WebConfig1)
}



As you can see there isn't much to it. If you are wondering why I am using the registry entry instead of hardcoding a path. That is because I wanted the script to be usable across any box with a catalog role without having to remember to update a script.

Comments

Popular posts from this blog

Intune Hybrid - NDES Cert Issue

Stuck @ "Waiting for user logon"

Triggering a software update install via Powershell