Created
February 19, 2020 09:39
-
-
Save Robert-LTH/f40d0be6ed3562c7ba6a47d8f25b53a9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.SYNOPSIS | |
Removes a QueryPanePageDescription from the details of an object in the MEMCM Admin Console | |
.DESCRIPTION | |
Reads the supplied XML-file and finds the node on which it will remove a PanePageDescription element. | |
This means that it will remove a tab from the details of an object in MEMCM. | |
The supplied example removes a tab from applications. | |
.EXAMPLE | |
$Params = @{ | |
XMLPath = "C:\temp\SoftwareLibraryNode.xml" | |
PageGuid = '69a869eb-54f3-40f0-bab1-83bb4fcf2501' | |
RootNodeGuid = 'd2e2cba7-98f5-4d3b-bc2f-b670f0621207' | |
RootQueryGuid = '968164ab-af86-459c-b89e-d3a49c05d367' | |
ObjectClass = 'SMS_Application' | |
} | |
Remove-QueryPanePageDescription @Params | |
.NOTES | |
Written by Robert-LTH (https://github.com/robert-lth) | |
Tested on | |
SCCM 1902 | |
SCCM 1906 | |
#> | |
function Remove-QueryPanePageDescriptionNode { | |
param( | |
[Parameter(Mandatory=$true)] | |
[ValidateNotNullOrEmpty()] | |
[ValidatePattern("[a-zA-Z0-9]{8}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{12}")] | |
[string]$PageGuid, | |
[Parameter(Mandatory=$true)] | |
[ValidateNotNullOrEmpty()] | |
[ValidatePattern("[a-zA-Z0-9]{8}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{12}")] | |
[string]$RootNodeGuid, | |
[Parameter(Mandatory=$true)] | |
[ValidateNotNullOrEmpty()] | |
[ValidatePattern("[a-zA-Z0-9]{8}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{12}")] | |
[string]$RootQueryGuid, | |
[Parameter(Mandatory=$true)] | |
[ValidateNotNullOrEmpty()] | |
[string]$ObjectClass, | |
[Parameter(Mandatory=$true)] | |
[ValidateNotNullOrEmpty()] | |
[ValidateScript({Test-Path -PathType Leaf -Path $_})] | |
[string]$XMLPath | |
) | |
try { | |
$XMLDocument = [xml](Get-Content -Path $XMLPath) | |
} | |
catch [System.Management.Automation.RuntimeException] { | |
throw "There was an error processing the xml-content" | |
} | |
# Find the right node to remove the pane from | |
$PageList = $XMLDocument.SelectNodes("//RootNodeDescription[@NamespaceGuid='$RootNodeGuid']/Queries/QueryDescription[@NamespaceGuid='$RootQueryGuid']/DetailsPaneDescription[@ObjectClass='$ObjectClass']/PageList") | |
# If the parameters were incorrect it will not find the right nodelist | |
if (($PageList | Measure-Object -Property ChildNodes).Count -le 0) { | |
throw "Could not find the node, verify that the parameters RootNodeGuid,RootQueryGuid and ObjectClass is correct." | |
} | |
# Find the right node to remove | |
$PanePage = $PageList.SelectNodes("PanePageDescription[@PageGuid='$PageGuid']") | |
if (($PanePage | Measure-Object -Property ChildNodes).Count -gt 0) { | |
# Remove the element from the parent element | |
$PageList.RemoveChild($panePage) | Out-Null | |
# Save the file | |
$XMLDocument.Save($XMLPath) | |
Write-Verbose "Saved '$XMLPath' with the added content." | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment