This is just a quick article on how to search for exe’s recursively in a specific path and add them to an RES Workspace Manager building block to be imported back in.
I needed to do this recently as the customer in question had an application that lived on a network share and after 14+ years of development in this style, everyone was afraid to move it!
Steps to use this script:
- Export an existing building block for the application you wish to authorize
- Ensure the exported building block has at least one authorized file
- Modify the $import and $exportbuildingblockpath
- Modify the $exedirpath to be the path you wish to search recursively for exe’s.
$importBuildingBlockPath = 'H:\path\bb.xml'
$exportBuildingBlockPath = 'h:\path\export.xml'
$alreadyauth=@()
$ExeForAuth=@()
$exedirpath = "\\servername\Share\APPS"
Get-ChildItem -Recurse $dirpath | ?{!($_.psiscontainer) -and $_.Extension -like ".exe"} | %{
$ExeForAuth+=$_.fullname.ToLower()
}
[xml]$bb = Get-Content $importBuildingBlockPath
$bb.respowerfuse.buildingblock.application.appguard.authorizedfiles.authfile | %{
$alreadyauth+=$_.authorizedfile.tolower()
}
Compare-Object $alreadyauth $ExeForAuth | ? {$_.SideIndicator -eq "=>"} | % {
$newnode=$bb.respowerfuse.buildingblock.application.appguard.authorizedfiles.authfile[0].Clone()
$newnode.authorizedfile=$_.inputobject.tostring()
$newnode.description="Auto Appended item via script"
$newnode.process="*"
$newnode.learningmode="no"
$newnode.enabled="yes"
$bb.respowerfuse.buildingblock.application.appguard.authorizedfiles.AppendChild($newnode)
}
$bb.save($exportBuildingBlockPath)









Happy scripting Friday!