Skip to content

Instantly share code, notes, and snippets.

View gist:4e50193e8c715e46c1e926bbcc645a4b
$MP = "Microsoft.Windows.Server.2003"
$path = "C:\folder\XML.to.Clean.Up.xml"
$xml = [xml](get-content $path)
$references = $xml.ManagementPack.Manifest.References.Reference | ? id -like "*$mp*"
foreach($reference in $references)
{$references.parentnode.RemoveChild($reference)}
$Diagnostics = $xml.ManagementPack.Monitoring.diagnostics.diagnostic | ? target -like "*$mp*"
foreach($Diagnostic in $Diagnostics)
View test.xml
<?xml version="1.0" encoding="utf-8"?><ManagementPack ContentReadable="true" SchemaVersion="2.0" OriginalSchemaVersion="1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<Manifest>
<References>
<Reference Alias="Windows3">
<ID>Microsoft.Windows.Server.2003</ID>
<Version>6.0.6989.0</Version>
<PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
</Reference>
</References>
View gist:d44d5bec35a71f45214c30c14b80e3d3
#v4
Measure-Command { foreach($source in $sources)
{
$sourcepath = $source.path.replace('\','/')
$count = $allstats.sourcefilename.Where({$_ -like "*$sourcepath*"}).count
$array += [pscustomobject]@{count = $count; path = $source.path}
}
}
#v5
View gist:2af417b7eb6301a0c6b6ef323f0709d1
#v2
Measure-Command {foreach($source in $sources)
{
$count = 0
foreach($allstat in $allstats)
{
$sourcepath = $source.path.replace('\','/')
if($allstat.sourcefilename -like "*$sourcepath*")
{
$count++
View gist:de7fafec1255a50174fc6746449897ac
foreach($source in $sources)
{
$sourcepath = $source.path.replace('\','/')
$count = ($allstats | ? sourcefilename -like "*$sourcepath*").count
$array += [pscustomobject]@{count = $count; path = $source.path}
}
View sample.xml
<settings>
<hosts>
<FTP ID="459" Name="*Test Prod FTP" > </FTP>
<SSHFTP ID="741" Name="*Test UA SSH" > </SSHFTP>
<Share ID="832" Name="\\server\share" > </Share>
<FTP ID="451" Name="*Test FTP" > </FTP>
View testrdg.rdg
<?xml version="1.0" encoding="utf-8"?>
<RDCMan programVersion="2.7" schemaVersion="3">
<file>
<credentialsProfiles />
<properties>
<expanded>True</expanded>
<name>testrdg</name>
</properties>
<group>
<properties>