In my article Reading Ivanti Workspace Control Building Block XML data and export to a CSV file or HTML Page, I wrote about a script to read all the Ivanti Building Block XML files and export the data to a CSV file or HTML page. Now, I created a new script that shows the output in a nice GUI. Also, there are some additional features:

  • Search for building blocks that match some criteria, like AppID, Title, command line etc.
  • Copy building blocks that match the criteria to another location. That might be handy if you want to import these building blocks later.
  • The settings are written to the registry, so when you start the application again, you will get the same settings. But there is an option to clear these settings.

If you prefer, you can still use the silent option. Then, there is no GUI.

Under the hood, the same technique is used as in my article Reading Ivanti Workspace Control Building Block XML data and export to a CSV file or HTML Page. So, please, read that article for technical background information. 

There is one open item: if there are many building blocks to go through, the application may look like it hangs, but it is still processing the building blocks.

Some pictures:

Run the inventory

Search for all the building blocks in the given folder and its subfolders. The output is shown in the grid.

Result in the grid.

The results are in the grid.

Copy building blocks to another location.

You can copy the building blocks that match the search criteria to another location. That might be handy if you want to process them at a later stage. I used this option during an Edge migration. First, we made all the applications in the DEV environment. After testing we imported the building blocks in the ACC Ivanti environment. 

The copied files.

The copied files.

Save and exit.

Save and exit.

An HTML file with all the information.

An HTML file with all the information.

The information in the registry.

The information that has been stored in the registry. 

 

 

The help information:

 get-help "C:\tmp\InventoryIvantiApplicationBuildingBlocksWithGUI\InventoryIvantiApplicationBuildingBlocksWithGUI_v03.ps1" -Detailed

NAME
    C:\tmp\InventoryIvantiApplicationBuildingBlocksWithGUI\InventoryIvantiApplicationBuildingBlocksWithGUI_v03.ps1

SYNOPSIS
    Finds the Start Menu Items in Ivanti Workspace Control Building Blocks and export them to a CSV file.


SYNTAX
    C:\tmp\InventoryIvantiApplicationBuildingBlocksWithGUI\InventoryIvantiApplicationBuildingBlocksWithGUI_v03.ps1
    [-Silent] [-Directory <String>] [-OutputDirectory <String>] [-LogPath <String>] [-IncludeSubFolders]
    [-DetailedLogging] [-NoProgressBar] [-LookFor] [-ExactMatchLocation] [-ExactMatchContainer] [-InAppID <String[]>]
    [-InTitle <String[]>] [-InCommandLine <String[]>] [-InParameter <String[]>] [-InFileTypes <String[]>]
    [-InGroupOrUser <String[]>] [-InLocations <String[]>] [-InContainers <String[]>] [-CopyFiles] [-Summary]
    [-SaveAsHTMLPage] [-NoUserSettings] [-ClearUserSettings] [-To <String>] [-Delimiter <String>] [<CommonParameters>]


DESCRIPTION
    An Ivanti Building Block contains all kind of information about a Start Menu item. This script exports the most
    used details to a CSV file.


PARAMETERS
    -Silent [<SwitchParameter>]

    -Directory <String>

    -OutputDirectory <String>

    -LogPath <String>

    -IncludeSubFolders [<SwitchParameter>]

    -DetailedLogging [<SwitchParameter>]

    -NoProgressBar [<SwitchParameter>]

    -LookFor [<SwitchParameter>]

    -ExactMatchLocation [<SwitchParameter>]

    -ExactMatchContainer [<SwitchParameter>]

    -InAppID <String[]>

    -InTitle <String[]>

    -InCommandLine <String[]>

    -InParameter <String[]>

    -InFileTypes <String[]>

    -InGroupOrUser <String[]>

    -InLocations <String[]>

    -InContainers <String[]>

    -CopyFiles [<SwitchParameter>]

    -Summary [<SwitchParameter>]

    -SaveAsHTMLPage [<SwitchParameter>]

    -NoUserSettings [<SwitchParameter>]

    -ClearUserSettings [<SwitchParameter>]

    -To <String>

    -Delimiter <String>

    <CommonParameters>
        This cmdlet supports the common parameters: Verbose, Debug,
        ErrorAction, ErrorVariable, WarningAction, WarningVariable,
        OutBuffer, PipelineVariable, and OutVariable. For more information, see
        about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).

    -------------------------- EXAMPLE 1 --------------------------

    PS C:\>Run an inventory on all the building blocks in the folder \\server\path\to\xmlfiles

    ."InventoryIvantiApplicationBuildingBlocksWithGUI_v03.ps1" -Directory \\server\path\to\xmlfiles




    -------------------------- EXAMPLE 2 --------------------------

    PS C:\>Run an inventory on all the building blocks in the folder \\server\path\to\xmlfiles. Only show a limited
    set of columns.

    ."InventoryIvantiApplicationBuildingBlocksWithGUI_v03.ps1" -Directory \\server\path\to\xmlfiles -Summary




    -------------------------- EXAMPLE 3 --------------------------

    PS C:\>Run an inventory on all the building blocks in the folder \\server\path\to\xmlfiles and its subfolders

    ."InventoryIvantiApplicationBuildingBlocksWithGUI_v03.ps1" -Directory \\server\path\to\xmlfiles -IncludeSubFolders




    -------------------------- EXAMPLE 4 --------------------------

    PS C:\>Run an inventory on all the building blocks in the folder \\server\path\to\xmlfiles and store the result
    file in c:\tmp

    ."InventoryIvantiApplicationBuildingBlocksWithGUI_v03.ps1" -Directory \\server\path\to\xmlfiles -IncludeSubFolders
    -OutputDirectory c:\tmp




    -------------------------- EXAMPLE 5 --------------------------

    PS C:\>Run an inventory on all the building blocks in the folder \\server\path\to\xmlfiles and store the result
    file in c:\tmp

    Do not show a progress bar.
    ."InventoryIvantiApplicationBuildingBlocksWithGUI_v03.ps1" -Directory \\server\path\to\xmlfiles -IncludeSubFolders
    -OutputDirectory c:\tmp -NoProgressBar




    -------------------------- EXAMPLE 6 --------------------------

    PS C:\>Run an inventory on all the building blocks in the folder \\server\path\to\xmlfiles and store the result
    file in c:\tmp.

    The delimiter character is ','
    ."InventoryIvantiApplicationBuildingBlocksWithGUI_v03.ps1" -Directory \\server\path\to\xmlfiles -IncludeSubFolders
    -OutputDirectory c:\tmp -Delimiter ","




    -------------------------- EXAMPLE 7 --------------------------

    PS C:\>Run an inventory on all the building blocks in the folder \\server\path\to\xmlfiles and store the result
    file in c:\tmp

    Check if the executable excel.exe or winword.exe is used in the commandline
    ."InventoryIvantiApplicationBuildingBlocksWithGUI_v03.ps1" -Directory \\server\path\to\xmlfiles -IncludeSubFolders
    -OutputDirectory c:\tmp -LookFor -InCommandLine excel.exe,winword.exe




    -------------------------- EXAMPLE 8 --------------------------

    PS C:\>Run an inventory on all the building blocks in the folder \\server\path\to\xmlfiles and store the result
    file in c:\tmp

    Check if Microsoft is used in the title.
    ."InventoryIvantiApplicationBuildingBlocksWithGUI_v03.ps1" -Directory \\server\path\to\xmlfiles -IncludeSubFolders
    -OutputDirectory c:\tmp -LookFor -InTitle Office




    -------------------------- EXAMPLE 9 --------------------------

    PS C:\>Run an inventory on all the building blocks in the folder \\server\path\to\xmlfiles and store the result
    file in c:\tmp

    Check if Microsoft is used in the title. Use detailed logging to a log file in c:\logging
    ."InventoryIvantiApplicationBuildingBlocksWithGUI_v03.ps1" -Directory \\server\path\to\xmlfiles -IncludeSubFolders
    -OutputDirectory c:\tmp -LogDir c:\logging -LookFor -InTitle Office -DetailedLogging




    -------------------------- EXAMPLE 10 --------------------------

    PS C:\>Run an inventory on all the building blocks in the folder \\server\path\to\xmlfiles and store the result
    file in c:\tmp for AppID 4321.

    Use detailed logging to a log file in c:\logging
    ."InventoryIvantiApplicationBuildingBlocksWithGUI_v03.ps1" -Directory \\server\path\to\xmlfiles -IncludeSubFolders
    -OutputDirectory c:\tmp -LookFor -InAppID 4321 -DetailedLogging -LogPath c:\logging




    -------------------------- EXAMPLE 11 --------------------------

    PS C:\>Run an inventory on all the building blocks in the folder \\server\path\to\xmlfiles and store the result
    file in c:\tmp

    Check if the group name 'Appl_Visio' is used.
    ."InventoryIvantiApplicationBuildingBlocksWithGUI_v03.ps1" -Directory \\server\path\to\xmlfiles -IncludeSubFolders
    -OutputDirectory c:\tmp -LookFor -InGroupName Appl_Visio




    -------------------------- EXAMPLE 12 --------------------------

    PS C:\>Run an inventory on all the building blocks in the folder \\server\path\to\xmlfiles and store the result
    file in c:\tmp

    Check if the container (workspace) name contains 'Test'.
    ."InventoryIvantiApplicationBuildingBlocksWithGUI_v03.ps1" -Directory \\server\path\to\xmlfiles -IncludeSubFolders
    -OutputDirectory c:\tmp -LookFor -InContainers Test




    -------------------------- EXAMPLE 13 --------------------------

    PS C:\>Run an inventory on all the building blocks in the folder \\server\path\to\xmlfiles and store the result
    file in c:\tmp

    Check if the container (workspace) name equals 'Test'.
    ."InventoryIvantiApplicationBuildingBlocksWithGUI_v03.ps1" -Directory \\server\path\to\xmlfiles -IncludeSubFolders
    -OutputDirectory c:\tmp -LookFor -InContainers Test -ExactMatchContainers




    -------------------------- EXAMPLE 14 --------------------------

    PS C:\>Run an inventory on all the building blocks in the folder \\server\path\to\xmlfiles and store the result
    file in c:\tmp

    Check if one of the file types cmd, bat, jnlp or jar is used.
    ."InventoryIvantiApplicationBuildingBlocksWithGUI_v03.ps1" -Directory \\server\path\to\xmlfiles -IncludeSubFolders
    -OutputDirectory c:\tmp -InFileTypes cmd,bat,jnlp,jar




    -------------------------- EXAMPLE 15 --------------------------

    PS C:\>Run an inventory on all the building blocks in the folder \\server\path\to\xmlfiles and store the result
    file in c:\tmp

    Copy all the building block files that have msedge.exe or iexplore.exe in the command line to c:\tmp-internet
    ."InventoryIvantiApplicationBuildingBlocksWithGUI_v03.ps1" -Directory \\server\path\to\xmlfiles -IncludeSubFolders
    -OutputDirectory c:\tmp -LookFor -InCommandLine msedge.exe,iexplore.exe -CopyFiles -To c:\tmp-internet




    -------------------------- EXAMPLE 16 --------------------------

    PS C:\>Run an inventory on all the building blocks in the folder \\server\path\to\xmlfiles and store the result
    file in c:\tmp

    Copy all the building block files that have msedge.exe or iexplore.exe in the command line to c:\tmp-internet
    Only show a limited set of columns and save it as a HTML page.
    ."InventoryIvantiApplicationBuildingBlocksWithGUI_v03.ps1" -Directory \\server\path\to\xmlfiles -IncludeSubFolders
    -OutputDirectory c:\tmp -LookFor -InCommandLine msedge.exe,iexplore.exe -CopyFiles -To c:\tmp-internet -Summary
    -SaveAsHTMLPage




    -------------------------- EXAMPLE 17 --------------------------

    PS C:\>Run an inventory on all the building blocks in the folder \\server\path\to\xmlfiles and store the result
    file in c:\tmp

    Copy all the building block files that have msedge.exe or iexplore.exe in the command line and as parameter
    www.google.com to c:\tmp-internet
    Only show a limited set of columns and save it as a HTML page.
    ."InventoryIvantiApplicationBuildingBlocksWithGUI_v03.ps1" -Directory \\server\path\to\xmlfiles -IncludeSubFolders
    -OutputDirectory c:\tmp -LookFor -InCommandLine msedge.exe,iexplore.exe -InParameter www.google.com -CopyFiles -To
    c:\tmp-internet -Summary -SaveAsHTMLPage




    -------------------------- EXAMPLE 18 --------------------------

    PS C:\>Run an inventory on all the building blocks in the folder \\server\path\to\xmlfiles and store the result
    file in c:\tmp

    Copy all the building block files that have msedge.exe or iexplore.exe in the command line and as parameter
    www.google.com to c:\tmp-internet
    Only show a limited set of columns and save it as a HTML page. Do not read or write the user settings to the
    registry.
    ."InventoryIvantiApplicationBuildingBlocksWithGUI_v03.ps1" -Directory \\server\path\to\xmlfiles -IncludeSubFolders
    -OutputDirectory c:\tmp -LookFor -InCommandLine msedge.exe,iexplore.exe -InParameter www.google.com -CopyFiles -To
    c:\tmp-internet -Summary -SaveAsHTMLPage -NoUserSettings




    -------------------------- EXAMPLE 19 --------------------------

    PS C:\>Run silently an inventory on all the building blocks in the folder \\server\path\to\xmlfiles and store the
    result file in c:\tmp

    Copy all the building block files that have msedge.exe or iexplore.exe in the command line to c:\tmp-internet
    ."InventoryIvantiApplicationBuildingBlocksWithGUI_v03.ps1" -Silent -Directory \\server\path\to\xmlfiles
    -IncludeSubFolders -OutputDirectory c:\tmp -LookFor -InCommandLine msedge.exe,iexplore.exe -CopyFiles -To
    c:\tmp-internet




    -------------------------- EXAMPLE 20 --------------------------

    PS C:\>Run silently an inventory on all the building blocks in the folder \\server\path\to\xmlfiles and store the
    result file in c:\tmp

    Copy all the building block files that have msedge.exe or iexplore.exe in the command line to c:\tmp-internet
    Only show a limited set of columns and save it as a HTML page.
    ."InventoryIvantiApplicationBuildingBlocksWithGUI_v03.ps1" -Silent -Directory \\server\path\to\xmlfiles
    -IncludeSubFolders -OutputDirectory c:\tmp -LookFor -InCommandLine msedge.exe,iexplore.exe -CopyFiles -To
    c:\tmp-internet -Summary -SaveAsHTMLPage




    -------------------------- EXAMPLE 21 --------------------------

    PS C:\>Run silently an inventory on all the building blocks in the folder \\server\path\to\xmlfiles and store the
    result file in c:\tmp

    Copy all the building block files that have msedge.exe or iexplore.exe in the command line and as parameter
    www.google.com to c:\tmp-internet
    Only show a limited set of columns and save it as a HTML page.
    ."InventoryIvantiApplicationBuildingBlocksWithGUI_v03.ps1" -Silent -Directory \\server\path\to\xmlfiles
    -IncludeSubFolders -OutputDirectory c:\tmp -LookFor -InCommandLine msedge.exe,iexplore.exe -InParameter
    www.google.com -CopyFiles -To c:\tmp-internet -Summary -SaveAsHTMLPage




    -------------------------- EXAMPLE 22 --------------------------

    PS C:\>Clear the settings from the registry.

    ."InventoryIvantiApplicationBuildingBlocksWithGUI_v03.ps1" -ClearUserSettings




REMARKS
    To see the examples, type: "get-help
    C:\tmp\InventoryIvantiApplicationBuildingBlocksWithGUI\InventoryIvantiApplicationBuildingBlocksWithGUI_v03.ps1
    -examples".
    For more information, type: "get-help
    C:\tmp\InventoryIvantiApplicationBuildingBlocksWithGUI\InventoryIvantiApplicationBuildingBlocksWithGUI_v03.ps1
    -detailed".
    For technical information, type: "get-help
    C:\tmp\InventoryIvantiApplicationBuildingBlocksWithGUI\InventoryIvantiApplicationBuildingBlocksWithGUI_v03.ps1
    -full".

And the Powershell script:

<#
.SYNOPSIS
    Finds the Start Menu Items in Ivanti Workspace Control Building Blocks and export them to a CSV file.

.DESCRIPTION
    An Ivanti Building Block contains all kind of information about a Start Menu item. This script exports the most used details to a CSV file. 

.EXAMPLE
    Run an inventory on all the building blocks in the folder \\server\path\to\xmlfiles
    ."InventoryIvantiApplicationBuildingBlocksWithGUI_v03.ps1" -Directory \\server\path\to\xmlfiles

.EXAMPLE
    Run an inventory on all the building blocks in the folder \\server\path\to\xmlfiles. Only show a limited set of columns.
    ."InventoryIvantiApplicationBuildingBlocksWithGUI_v03.ps1" -Directory \\server\path\to\xmlfiles -Summary

.EXAMPLE
    Run an inventory on all the building blocks in the folder \\server\path\to\xmlfiles and its subfolders
    ."InventoryIvantiApplicationBuildingBlocksWithGUI_v03.ps1" -Directory \\server\path\to\xmlfiles -IncludeSubFolders

.EXAMPLE
    Run an inventory on all the building blocks in the folder \\server\path\to\xmlfiles and store the result file in c:\tmp
    ."InventoryIvantiApplicationBuildingBlocksWithGUI_v03.ps1" -Directory \\server\path\to\xmlfiles -IncludeSubFolders -OutputDirectory c:\tmp

.EXAMPLE
    Run an inventory on all the building blocks in the folder \\server\path\to\xmlfiles and store the result file in c:\tmp
    Do not show a progress bar.
    ."InventoryIvantiApplicationBuildingBlocksWithGUI_v03.ps1" -Directory \\server\path\to\xmlfiles -IncludeSubFolders -OutputDirectory c:\tmp -NoProgressBar

.EXAMPLE
    Run an inventory on all the building blocks in the folder \\server\path\to\xmlfiles and store the result file in c:\tmp.
    The delimiter character is ','
    ."InventoryIvantiApplicationBuildingBlocksWithGUI_v03.ps1" -Directory \\server\path\to\xmlfiles -IncludeSubFolders -OutputDirectory c:\tmp -Delimiter ","

.EXAMPLE
    Run an inventory on all the building blocks in the folder \\server\path\to\xmlfiles and store the result file in c:\tmp
    Check if the executable excel.exe or winword.exe is used in the commandline
    ."InventoryIvantiApplicationBuildingBlocksWithGUI_v03.ps1" -Directory \\server\path\to\xmlfiles -IncludeSubFolders -OutputDirectory c:\tmp -LookFor -InCommandLine excel.exe,winword.exe

.EXAMPLE
    Run an inventory on all the building blocks in the folder \\server\path\to\xmlfiles and store the result file in c:\tmp
    Check if Microsoft is used in the title.
    ."InventoryIvantiApplicationBuildingBlocksWithGUI_v03.ps1" -Directory \\server\path\to\xmlfiles -IncludeSubFolders -OutputDirectory c:\tmp -LookFor -InTitle Office

.EXAMPLE
    Run an inventory on all the building blocks in the folder \\server\path\to\xmlfiles and store the result file in c:\tmp
    Check if Microsoft is used in the title. Use detailed logging to a log file in c:\logging
    ."InventoryIvantiApplicationBuildingBlocksWithGUI_v03.ps1" -Directory \\server\path\to\xmlfiles -IncludeSubFolders -OutputDirectory c:\tmp -LogDir c:\logging -LookFor -InTitle Office -DetailedLogging

.EXAMPLE
    Run an inventory on all the building blocks in the folder \\server\path\to\xmlfiles and store the result file in c:\tmp for AppID 4321. 
    Use detailed logging to a log file in c:\logging
    ."InventoryIvantiApplicationBuildingBlocksWithGUI_v03.ps1" -Directory \\server\path\to\xmlfiles -IncludeSubFolders -OutputDirectory c:\tmp -LookFor -InAppID 4321 -DetailedLogging -LogPath c:\logging

.EXAMPLE
    Run an inventory on all the building blocks in the folder \\server\path\to\xmlfiles and store the result file in c:\tmp
    Check if the group name 'Appl_Visio' is used.
    ."InventoryIvantiApplicationBuildingBlocksWithGUI_v03.ps1" -Directory \\server\path\to\xmlfiles -IncludeSubFolders -OutputDirectory c:\tmp -LookFor -InGroupName Appl_Visio

.EXAMPLE
    Run an inventory on all the building blocks in the folder \\server\path\to\xmlfiles and store the result file in c:\tmp
    Check if the container (workspace) name contains 'Test'.
    ."InventoryIvantiApplicationBuildingBlocksWithGUI_v03.ps1" -Directory \\server\path\to\xmlfiles -IncludeSubFolders -OutputDirectory c:\tmp -LookFor -InContainers Test

.EXAMPLE
    Run an inventory on all the building blocks in the folder \\server\path\to\xmlfiles and store the result file in c:\tmp
    Check if the container (workspace) name equals 'Test'.
    ."InventoryIvantiApplicationBuildingBlocksWithGUI_v03.ps1" -Directory \\server\path\to\xmlfiles -IncludeSubFolders -OutputDirectory c:\tmp -LookFor -InContainers Test -ExactMatchContainers

.EXAMPLE
    Run an inventory on all the building blocks in the folder \\server\path\to\xmlfiles and store the result file in c:\tmp
    Check if one of the file types cmd, bat, jnlp or jar is used.
    ."InventoryIvantiApplicationBuildingBlocksWithGUI_v03.ps1" -Directory \\server\path\to\xmlfiles -IncludeSubFolders -OutputDirectory c:\tmp -InFileTypes cmd,bat,jnlp,jar

.EXAMPLE
    Run an inventory on all the building blocks in the folder \\server\path\to\xmlfiles and store the result file in c:\tmp
    Copy all the building block files that have msedge.exe or iexplore.exe in the command line to c:\tmp-internet
    ."InventoryIvantiApplicationBuildingBlocksWithGUI_v03.ps1" -Directory \\server\path\to\xmlfiles -IncludeSubFolders -OutputDirectory c:\tmp -LookFor -InCommandLine msedge.exe,iexplore.exe -CopyFiles -To c:\tmp-internet

.EXAMPLE
    Run an inventory on all the building blocks in the folder \\server\path\to\xmlfiles and store the result file in c:\tmp
    Copy all the building block files that have msedge.exe or iexplore.exe in the command line to c:\tmp-internet
    Only show a limited set of columns and save it as a HTML page.
    ."InventoryIvantiApplicationBuildingBlocksWithGUI_v03.ps1" -Directory \\server\path\to\xmlfiles -IncludeSubFolders -OutputDirectory c:\tmp -LookFor -InCommandLine msedge.exe,iexplore.exe -CopyFiles -To c:\tmp-internet -Summary -SaveAsHTMLPage

.EXAMPLE
    Run an inventory on all the building blocks in the folder \\server\path\to\xmlfiles and store the result file in c:\tmp
    Copy all the building block files that have msedge.exe or iexplore.exe in the command line and as parameter www.google.com to c:\tmp-internet
    Only show a limited set of columns and save it as a HTML page.
    ."InventoryIvantiApplicationBuildingBlocksWithGUI_v03.ps1" -Directory \\server\path\to\xmlfiles -IncludeSubFolders -OutputDirectory c:\tmp -LookFor -InCommandLine msedge.exe,iexplore.exe -InParameter www.google.com -CopyFiles -To c:\tmp-internet -Summary -SaveAsHTMLPage

.EXAMPLE
    Run an inventory on all the building blocks in the folder \\server\path\to\xmlfiles and store the result file in c:\tmp
    Copy all the building block files that have msedge.exe or iexplore.exe in the command line and as parameter www.google.com to c:\tmp-internet
    Only show a limited set of columns and save it as a HTML page. Do not read or write the user settings to the registry.
    ."InventoryIvantiApplicationBuildingBlocksWithGUI_v03.ps1" -Directory \\server\path\to\xmlfiles -IncludeSubFolders -OutputDirectory c:\tmp -LookFor -InCommandLine msedge.exe,iexplore.exe -InParameter www.google.com -CopyFiles -To c:\tmp-internet -Summary -SaveAsHTMLPage -NoUserSettings

.EXAMPLE
    Run silently an inventory on all the building blocks in the folder \\server\path\to\xmlfiles and store the result file in c:\tmp
    Copy all the building block files that have msedge.exe or iexplore.exe in the command line to c:\tmp-internet
    ."InventoryIvantiApplicationBuildingBlocksWithGUI_v03.ps1" -Silent -Directory \\server\path\to\xmlfiles -IncludeSubFolders -OutputDirectory c:\tmp -LookFor -InCommandLine msedge.exe,iexplore.exe -CopyFiles -To c:\tmp-internet

.EXAMPLE
    Run silently an inventory on all the building blocks in the folder \\server\path\to\xmlfiles and store the result file in c:\tmp
    Copy all the building block files that have msedge.exe or iexplore.exe in the command line to c:\tmp-internet
    Only show a limited set of columns and save it as a HTML page.
    ."InventoryIvantiApplicationBuildingBlocksWithGUI_v03.ps1" -Silent -Directory \\server\path\to\xmlfiles -IncludeSubFolders -OutputDirectory c:\tmp -LookFor -InCommandLine msedge.exe,iexplore.exe -CopyFiles -To c:\tmp-internet -Summary -SaveAsHTMLPage

.EXAMPLE
    Run silently an inventory on all the building blocks in the folder \\server\path\to\xmlfiles and store the result file in c:\tmp
    Copy all the building block files that have msedge.exe or iexplore.exe in the command line and as parameter www.google.com to c:\tmp-internet
    Only show a limited set of columns and save it as a HTML page.
    ."InventoryIvantiApplicationBuildingBlocksWithGUI_v03.ps1" -Silent -Directory \\server\path\to\xmlfiles -IncludeSubFolders -OutputDirectory c:\tmp -LookFor -InCommandLine msedge.exe,iexplore.exe -InParameter www.google.com -CopyFiles -To c:\tmp-internet -Summary -SaveAsHTMLPage

.EXAMPLE
    Clear the settings from the registry.
    ."InventoryIvantiApplicationBuildingBlocksWithGUI_v03.ps1" -ClearUserSettings

.NOTES
    Author:  Willem-Jan Vroom
    Website: https://www.vroom.cc/
    Twitter: @TheStingPilot

v0.1:
   * Initial version.

v0.2:
   * Logging in GUI modified.
   * Introduction of the following parameters:
          - OutputDirectory
          - ExactMatchLocation
          - ExactMatchContainer
   * Solved the bug that the Summary parameter did not work.
   * Summary also visible in the results view.

v0.3:
   * The settings are stored in the registry under HKCU:\Software\VroomSoft\InventoryIvantiBuildingBlocks
   * Introduction of the following parameters:
          - NoUserSettings
          - ClearUserSettings
   * Tooltips
   * The authorized operation from Security -> Authorized Files -> Authorized file -> Authorized process are mentioned clearly in the overview.

   #>

[CmdletBinding(DefaultParameterSetName = 'Default')]

Param
  (
   [Parameter(HelpMessage='Perform all the actions silently.')]
   [Parameter(Mandatory=$False,  ParameterSetName='Default')]
   [Switch]   $Silent,
   
   [Parameter(HelpMessage='Specify the directory that contains all the exported building blocks.')]
   [Parameter(Mandatory=$False,  ParameterSetName='Default')]
   [String]   $Directory = "",

   [Parameter(HelpMessage='Specify the directory where the CSV or HTML file should be saved.')]
   [Parameter(Mandatory=$False,  ParameterSetName='Default')]
   [String]   $OutputDirectory = "",

   [Parameter(HelpMessage='Specify the log directory.')]
   [Parameter(Mandatory=$False, ParameterSetName='Default')]
   [String]   $LogPath = "",

   [Parameter(HelpMessage='Include subfolders for the directory that contains all the exported building blocks.')]
   [Parameter(Mandatory=$False, ParameterSetName='Default')]
   [Switch]   $IncludeSubFolders,

   [Parameter(HelpMessage='Enable detailed logging to a log file.')]
   [Parameter(Mandatory=$False, ParameterSetName='Default')]
   [Switch]   $DetailedLogging,

   [Parameter(HelpMessage='Disable the progress bar.')]
   [Parameter(Mandatory=$False, ParameterSetName='Default')]
   [Switch]   $NoProgressBar,

   [Parameter(HelpMessage='Enable lookfor.')]
   [Parameter(Mandatory=$False, ParameterSetName='Default')]
   [Switch]   $LookFor,

   [Parameter(HelpMessage='Exact match on the location.')]
   [Parameter(Mandatory=$False, ParameterSetName='Default')]
   [Switch]   $ExactMatchLocation,

   [Parameter(HelpMessage='Exact match on the container.')]
   [Parameter(Mandatory=$False, ParameterSetName='Default')]
   [Switch]   $ExactMatchContainer,

   [Parameter(HelpMessage='Specify each AppID to search for, may be seperated by a comma.')]
   [Parameter(Mandatory=$False, ParameterSetName='Default')]
   [String[]] $InAppID,

   [Parameter(HelpMessage='Specify the items to search for in the title, may be seperated by a comma.')]
   [Parameter(Mandatory=$False, ParameterSetName='Default')]
   [String[]] $InTitle,

   [Parameter(HelpMessage='Specify the items to search for in the command line, may be seperated by a comma.')]
   [Parameter(Mandatory=$False, ParameterSetName='Default')]
   [String[]] $InCommandLine,

   [Parameter(HelpMessage='Specify the items to search for in the parameter line, may be seperated by a comma.')]
   [Parameter(Mandatory=$False, ParameterSetName='Default')]
   [String[]] $InParameter,

   [Parameter(HelpMessage='Specify the items to search for in the file types (file associations), may be seperated by a comma.')]
   [Parameter(Mandatory=$False, ParameterSetName='Default')]
   [String[]] $InFileTypes,

   [Parameter(HelpMessage='Specify the groups or users to search for. May be seperated by a comma.')]
   [Parameter(Mandatory=$False, ParameterSetName='Default')]
   [String[]] $InGroupOrUser,

   [Parameter(HelpMessage='Specify the Locations and Devices to search for. May be seperated by a comma.')]
   [Parameter(Mandatory=$False, ParameterSetName='Default')]
   [String[]] $InLocations,

   [Parameter(HelpMessage='Specify the Workspace Containers to search for. May be seperated by a comma.')]
   [Parameter(Mandatory=$False, ParameterSetName='Default')]
   [String[]] $InContainers,

   [Parameter(HelpMessage='Copy the files that are found with the LookFor parameter to a new location.')]
   [Parameter(Mandatory=$False, ParameterSetName='Default')]
   [Switch]   $CopyFiles,

   [Parameter(HelpMessage='Only display a limited set of columns.')]
   [Parameter(Mandatory=$False, ParameterSetName='Default')]
   [Switch]   $Summary,

   [Parameter(HelpMessage='Save as an HTML file.')]
   [Parameter(Mandatory=$False, ParameterSetName='Default')]
   [Switch]   $SaveAsHTMLPage,

   [Parameter(HelpMessage='Do not use the saved user settings and do not save the user settings on exit.')]
   [Parameter(Mandatory=$False, ParameterSetName='Default')]
   [Switch]   $NoUserSettings,

   [Parameter(HelpMessage='Clear the user settings from the registry.')]
   [Parameter(Mandatory=$False, ParameterSetName='Default')]
   [Switch]   $ClearUserSettings,

   [Parameter(HelpMessage='The location where the files have to be copied to.')]
   [Parameter(Mandatory=$False, ParameterSetName='Default')]
   [String]   $To,

   [Parameter(HelpMessage='Specify the delimiter character. Default = ;')]
   [Parameter(Mandatory=$False, ParameterSetName='Default')]
   [String]   $Delimiter = ";"

  )

# =============================================================================================================================================
# Function block
# =============================================================================================================================================

  Function Add-EntryToLogFile
   {

    <#
    .NOTES
    =============================================================================================================================================
    Created with:     Windows PowerShell ISE
    Created on:       17-May-2020
    Created by:       Willem-Jan Vroom
    Organization:     
    Functionname:     Add-EntryToLogFile
    =============================================================================================================================================
    .SYNOPSIS

    This function adds a line to a log file

    #>

    Param
     (
      [string] $Entry
     )
      
     Write-Verbose $Entry
     if($Global:gblDetailedLogging -and $Global:gblLogFile)
      {
       $Timestamp = (Get-Date -UFormat "%a %e %b %Y %X").ToString()
       Add-Content $Global:gblLogFile -Value $($Timestamp + " " + $Entry) -Force -ErrorAction SilentlyContinue
      }
   }

  Function Create-Folder
   {

    <#
    .NOTES
    =============================================================================================================================================
    Created with:     Windows PowerShell ISE
    Created on:       03-August-2018
    Created by:       Willem-Jan Vroom
    Organization:     
    Functionname:     Create-Folder
    =============================================================================================================================================
    .SYNOPSIS

    This function creates the given folder.
    The function returns two results:
     1. A message.
     2. True or false (success or failure)

    #>
    
    param
     (
      [String] $FolderName
     )

   $bolResult     = $True
   $ResultMessage = ""

   if(-not(Test-Path $('FileSystem::' + $FolderName)))
    {
     New-Item -Path $FolderName -ItemType Directory | Out-Null
     Sleep 1
     if(test-path $('FileSystem::' + $FolderName))
      {
       $ResultMessage = "The folder '$FolderName' has been created."
      }
       else
      {
       $ResultMessage = "Something went wrong while creating the folder '$FolderName'. "
       $bolResult     = $false
      }
    }
     else
    {
     $ResultMessage = "The folder $FolderName already exists."
    }

    Return $ResultMessage,$bolResult 

   }

  Function Add-EntryToResultsFile
   {

    <#
    .NOTES
    =============================================================================================================================================
    Created with:     Windows PowerShell ISE
    Created on:       03-August-2018
    Created by:       Willem-Jan Vroom
    Organization:     
    Functionname:     Add-EntryToResultsFile
    =============================================================================================================================================
    .SYNOPSIS

    This function adds the success or failure information to the array that contains the log
    information.

    #>

    Param
     (
      [String]  $XMLFileName                       = "",
      [Int]     $NumberOfApplications              = 9999,
      [String]  $StartMenu                         = "",
      [String]  $appid                             = "",
      [String]  $Title                             = "",
      [String]  $Description                       = "",
      [String]  $Commandline                       = "",
      [String]  $Workingdir                        = "",
      [String]  $Parameters                        = "",
      [String]  $appv5packagemode                  = "",
      [String]  $appv5packagefile                  = "",
      [String]  $appv5deploymentconfigurationfile  = "",
      [String]  $appv5userconfigurationfile        = "",
      [String]  $appv5packageupdate                = "",
      [String]  $appv5packageroot                  = "",
      [String]  $administrativenote                = "",
      [String]  $unmanagedshortcuts                = "",
      [String]  $createmenushortcut                = "",
      [String]  $allowmultipleshortcuts            = "",
      [String]  $Enabled                           = "",
      [String]  $hidefrommenu                      = "",
      [String]  $checkappexists                    = "",
      [String]  $checkfileexists                   = "",
      [string]  $FileTypesInTable                  = "",
      [String]  $accesstype                        = "",
      [String]  $GroupList                         = "",
      [String]  $PowerZones                        = "",
      [String]  $Workspaces                        = "",
      [String]  $LearningMode                      = "",
      [String]  $AppGuard                          = "",
      [String]  $ApplicationContainsLinkedActions  = "",
      [String]  $ApplicationContainsLinkedSettings = "",
      [String]  $Remark                            = ""
     )

    $Record  = [ordered] @{"XML File Name"                                                           = "";
                           "Number of applications"                                                  = "";
                           "Start Menu location"                                                     = "";
                           "Properties - General - ID"                                               = "";
                           "Properties - General - Title"                                            = "";
                           "Properties - General - Description"                                      = "";
                           "Properties - General - Commandline"                                      = "";
                           "Properties - General - Working directory"                                = "";
                           "Properties - General - Parameters"                                       = "";
                           "Properties - General - AppV5 Package delivery mode"                      = "";
                           "Properties - General - AppV5 Package file"                               = "";
                           "Properties - General - AppV5 Deployment configuration file"              = "";
                           "Properties - General - AppV5 User configuration file"                    = "";
                           "Properties - General - AppV5 Always use latest version"                  = "";
                           "Properties - General - AppV5 Package root folder"                        = "";
                           "Properties - General - Administrative note"                              = "";
                           "Properties - Shortcuts - Replace existing unmanaged shortcuts"           = "";
                           "Properties - Shortcuts - Create Start Menu shortcut"                     = "";
                           "Properties - Shortcuts - Allow multiple shortcuts in Start Menu"         = "";
                           "Properties - Settings - Application is enabled"                          = "";
                           "Properties - Settings - Hide application"                                = "";
                           "Properties - Settings - Hide application if executable was not found"    = "";
                           "Properties - Settings - Hide application if file was not found"          = "";
                           "Properties - FileTypes"                                                  = "";
                           "Access Control - Identy - Type"                                          = "";
                           "Access Control - Identy - Selected users and/or groups"                  = "";
                           "Access Control - Location and devices"                                   = "";
                           "Access Control - Workspace containers"                                   = "";
                           "Security - Authorized Files - Run this application in learning mode"     = "";
                           "Security - Authorized Files - Authorized file"                           = "";
                           "Configuration - Actions - At application start contains linked actions"  = "";
                           "User settings - Properties contains user settings from other application"= "";
                           "Remark"                                                                  = ""
                           }
                               
    $Record."XML File Name"                                                            = $XMLFileName
    $Record."Number of applications"                                                   = $NumberOfApplications
    $Record."Start Menu location"                                                      = $StartMenu
    $Record."Properties - General - ID"                                                = $appid
    $Record."Properties - General - Title"                                             = $Title
    $Record."Properties - General - Description"                                       = $Description
    $Record."Properties - General - Commandline"                                       = $Commandline
    $Record."Properties - General - Working directory"                                 = $Workingdir
    $Record."Properties - General - Parameters"                                        = $Parameters
    $Record."Properties - General - AppV5 Package delivery mode"                       = $appv5packagemode
    $Record."Properties - General - AppV5 Package file"                                = $appv5packagefile
    $Record."Properties - General - AppV5 Deployment configuration file"               = $appv5deploymentconfigurationfile
    $Record."Properties - General - AppV5 User configuration file"                     = $appv5userconfigurationfile
    $Record."Properties - General - AppV5 Always use latest version"                   = $appv5packageupdate
    $Record."Properties - General - AppV5 Package root folder"                         = $appv5packageroot
    $Record."Properties - General - Administrative note"                               = $administrativenote
    $Record."Properties - Shortcuts - Replace existing unmanaged shortcuts"            = $unmanagedshortcuts
    $Record."Properties - Shortcuts - Create Start Menu shortcut"                      = $createmenushortcut
    $Record."Properties - Shortcuts - Allow multiple shortcuts in Start Menu"          = $allowmultipleshortcuts
    $Record."Properties - Settings - Application is enabled"                           = $Enabled
    $Record."Properties - Settings - Hide application"                                 = $hidefrommenu
    $Record."Properties - Settings - Hide application if executable was not found"     = $checkappexists
    $Record."Properties - FileTypes"                                                   = $FileTypesInTable
    $Record."Access Control - Identy - Type"                                           = $accesstype
    $Record."Access Control - Identy - Selected users and/or groups"                   = $GroupList
    $Record."Access Control - Location and devices"                                    = $PowerZones
    $Record."Access Control - Workspace containers"                                    = $Workspaces
    $Record."Configuration - Actions - At application start contains linked actions"   = $ApplicationContainsLinkedActions
    $Record."User settings - Properties contains user settings from other application" = $ApplicationContainsLinkedSettings
    $Record."Security - Authorized Files - Run this application in learning mode"      = $LearningMode
    $Record."Security - Authorized Files - Authorized file"                            = $AppGuard
    $Record."Remark"                                                                   = $Remark

    $objRecord                           = New-Object PSObject -Property $Record
    $Global:gblarrTable                    += $objRecord

    Add-EntryToLogFile -Entry  "       XML File Name:                                                            $XMLFileName"
    Add-EntryToLogFile -Entry  "       Start Menu location:                                                      $StartMenu"
    Add-EntryToLogFile -Entry  "       Number of applications                                                    $NumberOfApplications"
    Add-EntryToLogFile -Entry  "       Properties - General - ID:                                                $appid"
    Add-EntryToLogFile -Entry  "       Properties - General - Title:                                             $Title"
    Add-EntryToLogFile -Entry  "       Properties - General - Description:                                       $Description"
    Add-EntryToLogFile -Entry  "       Properties - General - Commandline:                                       $Commandline"
    Add-EntryToLogFile -Entry  "       Properties - General - Working directory:                                 $Workingdir"                      
    Add-EntryToLogFile -Entry  "       Properties - General - Parameters:                                        $Parameters"
    Add-EntryToLogFile -Entry  "       Properties - General - AppV5 Package delivery mode:                       $appv5packagemode"
    Add-EntryToLogFile -Entry  "       Properties - General - AppV5 Package file:                                $appv5packagefile"   
    Add-EntryToLogFile -Entry  "       Properties - General - AppV5 Deployment configuration file:               $appv5deploymentconfigurationfile"            
    Add-EntryToLogFile -Entry  "       Properties - General - AppV5 User configuration file:                     $appv5userconfigurationfile"                  
    Add-EntryToLogFile -Entry  "       Properties - General - AppV5 Always use latest version:                   $appv5packageupdate"
    Add-EntryToLogFile -Entry  "       Properties - General - AppV5 Package root folder:                         $appv5packageroot"                       
    Add-EntryToLogFile -Entry  "       Properties - General - Administrative note:                               $administrativenote"
    Add-EntryToLogFile -Entry  "       Properties - Shortcuts - Replace existing unmanaged shortcuts:            $unmanagedshortcuts"           
    Add-EntryToLogFile -Entry  "       Properties - Shortcuts - Create Start Menu shortcut:                      $createmenushortcut"
    Add-EntryToLogFile -Entry  "       Properties - Shortcuts - Allow multiple shortcuts in Start Menu:          $allowmultipleshortcuts"       
    Add-EntryToLogFile -Entry  "       Properties - Settings - Application is enabled:                           $Enabled"                         
    Add-EntryToLogFile -Entry  "       Properties - Settings - Hide application:                                 $hidefrommenu"
    Add-EntryToLogFile -Entry  "       Properties - Settings - Hide application if executable was not found:     $checkappexists"   
    Add-EntryToLogFile -Entry  "       Properties - Settings - Hide application if file was not found:           $checkfileexists"
    Add-EntryToLogFile -Entry  "       Properties - FileTypes:                                                   $FileTypesInTable"
    Add-EntryToLogFile -Entry  "       Access Control - Identy - Type                                            $accesstype"
    Add-EntryToLogFile -Entry  "       Access Control - Identy - Selected users and/or groups:                   $GroupList"
    Add-EntryToLogFile -Entry  "       Access Control - Location and devices:                                    $PowerZones"                                   
    Add-EntryToLogFile -Entry  "       Access Control - Workspace containers:                                    $Workspaces"
    Add-EntryToLogFile -Entry  "       Configuration - Actions - At application start contains linked actions:   $ApplicationContainsLinkedActions"
    Add-EntryToLogFile -Entry  "       User settings - Properties contains user settings from other application: $ApplicationContainsLinkedSettings"
    Add-EntryToLogFile -Entry  "       Security - Authorized Files - Run this application in learning mode:      $LearningMode"
    Add-EntryToLogFile -Entry  "       Security - Authorized Files - Authorized file:                            $AppGuard"
    Add-EntryToLogFile -Entry  "       Remark:                                                                   $Remark"
    Add-EntryToLogFile -Entry  ""
    Add-EntryToLogFile -Entry  "###############################################################################################################`n"
   }

  Function CheckXMLFile
   {

    <#
    .NOTES
    =============================================================================================================================================
    Created with:     Windows PowerShell ISE
    Created on:       06-September-2018
    Created by:       Willem-Jan Vroom
    Organization:     
    Functionname:     CheckXMLFile
    =============================================================================================================================================
    .SYNOPSIS

    This function checks if the xml file is valid.

    #>

    param
     (
      [String]$XMLFile
     )

     $xml = New-Object System.Xml.XmlDocument

     Try
      {
       $xml.Load((Get-ChildItem -Path $XMLFile).FullName)
       Add-EntryToLogFile -Entry "------- The file $XMLFile is valid."
       Return $True
      }
       Catch
      {
       Add-EntryToLogFile -Entry "------- The file $XMLFile is not valid."
       Return $False
      }
   }

  Function Write-CSVFile
   {

    <#
    .NOTES
    =============================================================================================================================================
    Created with:     Windows PowerShell ISE
    Created on:       06-September-2018
    Created by:       Willem-Jan Vroom
    Organization:     
    Functionname:     Write-CSVFile
    =============================================================================================================================================
    .SYNOPSIS

    This function writes the logfile content to a CSV file.

    #>

    param
     (
      [String] $CSVOrHTMLFileWithResults
     )

    If($Global:gblarrTable.Count -gt 0)
     {
      If($Global:gblSummary)
       {
        $Global:gblarrTable = $Global:gblarrTable | Select-Object -Property "XML File Name","Start Menu location","Properties - General - ID","Properties - General - Title","Properties - General - Description","Properties - General - Commandline","Properties - General - Parameters","Properties - Settings - Application is enabled","Properties - FileTypes","Access Control - Identy - Type","Access Control - Identy - Selected users and/or groups","Access Control - Location and devices","Access Control - Workspace containers","Remark"
       }

      $Global:gblarrTable | Select-Object | Sort-Object -Property "Start Menu location","Properties - General - Title","Properties - General - ID" | Export-Csv $CSVOrHTMLFileWithResults -NoTypeInformation -Delimiter $Global:gblDelimiter
      Add-EntryToLogFile -Entry ">> Write-CSVFile: The file '$CSVOrHTMLFileWithResults' has been written."
      Write-Host "The file '$CSVOrHTMLFileWithResults' has been created."
     } 
      else
     {
      $ErrorMessage = "Something went wrong while writing the logfile '$CSVOrHTMLFileWithResults'. Maybe nothing to report..."
      Add-EntryToLogFile -Entry "[Error]: $ErrorMessage"
      Write-Error $ErrorMessage -Category CloseError 
     } 
   }

  Function Get-XMLDetailsForAccessInfo
   {

    <#
    .NOTES
    =============================================================================================================================================
    Created with:     Windows PowerShell ISE
    Created on:       26 April 2020
    Created by:       Willem-Jan Vroom
    Organization:     
    Functionname:     Get-XMLDetailsForAccessInfo
    =============================================================================================================================================
    .SYNOPSIS

    This function returns who has rights to use this application:
     - The users and groups
     - The application manager(s).
    #>
   
    Param
      (
       [xml]    $BuildingBlockDetails,
       [string] $XMLPath,
       [string] $accessmode,
       [string] $accesstype
      )
       
       $XMLPath = $XMLPath.Replace(".","/")
       $Return  = @()

     # =============================================================================================================================================
     # Users and groups
     # =============================================================================================================================================
       
       if ($accesstype -eq "group")
       
        {
         
        # =============================================================================================================================================
        # The users and groups are stored in 
        # respowerfuse.buildingblock.application.accesscontrol.grouplist.group
        # =============================================================================================================================================
         
         $GroupDetails  = @($BuildingBlockDetails | Select-Xml -XPath "/$XMLPath/grouplist/group").Node
                  
         if($GroupDetails)
          {
           Add-EntryToLogFile -Entry " Group Details:"
           forEach ($GroupDetail in $GroupDetails)
            {
             if(-not($Return))
              {
               $Type = $GroupDetail | Select-Object -ExpandProperty 'type' -ErrorAction SilentlyContinue
               Add-EntryToLogFile -Entry "  -> Type:  $Type"

               $Name = $GroupDetail | Select-Object -ExpandProperty '#text'
               Add-EntryToLogFile -Entry "  -> Name:  $Name"
               $Return = "$Name   ($($Type))"
              }
               else
              {
               $Type = $GroupDetail | Select-Object -ExpandProperty 'type' -ErrorAction SilentlyContinue
               Add-EntryToLogFile -Entry "  -> Type:  $Type"

               $Name = $GroupDetail | Select-Object -ExpandProperty '#text'
               Add-EntryToLogFile -Entry "  -> Name:  $Name"
               $Return += "`n$($accessmode) $($Name)   ($($Type))"
             }
            }
          
           $NotGroupDetails  = @($BuildingBlockDetails | Select-Xml -XPath "/$XMLPath/notgrouplist/group")
           if($NotGroupDetails)
            {
             $NotGroupDetails = ($NotGroupDetails).Node
             Add-EntryToLogFile -Entry " Not Group Details:"
             forEach ($NotGroupDetail in $NotGroupDetails)
              {
               $Type = $NotGroupDetail | Select-Object -ExpandProperty 'type'
               Add-EntryToLogFile -Entry "  -> Type:  $Type" 
               $Name = $NotGroupDetail | Select-Object -ExpandProperty '#text'
               Add-EntryToLogFile -Entry "  -> Name:  $Name"
               $Return += "`n    $($accessmode) NOT IN $($Name)   ($($Type))"
              }
            }
          }
       }

     # =============================================================================================================================================
     # Controlled by application managers.
     # =============================================================================================================================================

       elseif($accesstype -eq "delegated")
        {
        
       # =============================================================================================================================================
       # The controlled by application manager(s) are stored in 
       # respowerfuse.buildingblock.application.accesscontrol.appmanlist.appmanglobal
       # =============================================================================================================================================
               
         $AppplicationManagers = @($BuildingBlockDetails | Select-Xml -XPath "/$XMLPath/appmanlist/appmanglobal").Node
         
         Add-EntryToLogFile -Entry " Group Details:" 

         forEach ($AppplicationManager in $AppplicationManagers)
          {
           if(-not($Return))
            {
             $Name = $AppplicationManager | Select-Object -ExpandProperty '#text'
             Add-EntryToLogFile -Entry "  -> Name:  $Name"
             $Return = "$Name"
            }
             else
            {
             $Name = $AppplicationManager | Select-Object -ExpandProperty '#text'
             Add-EntryToLogFile -Entry "  -> Name:  $Name"
             $Return += "`n$($accessmode) $($Name)"
           }
          }
        }

     Add-EntryToLogFile -Entry "(Function: Get-XMLDetailsForAccessInfo) The return value for $XMLPath is $Return."

     Return $Return
   }

  Function Get-XMLDetailsForAuthorizedFiles
   {

    <#
    .NOTES
    =============================================================================================================================================
    Created with:     Windows PowerShell ISE
    Created on:       26 April 2020
    Created by:       Willem-Jan Vroom
    Organization:     
    Functionname:     Get-XMLDetailsForAuthorizedFiles
    =============================================================================================================================================
    .SYNOPSIS

    This function returns the authorized files.
    #>
   
    Param
      (
       [xml]    $BuildingBlockDetails,
       [string] $XMLPath,
       [string] $CommandLine
      )
       
     Add-EntryToLogFile -Entry "--> In function: Get-XMLDetailsForAuthorizedFiles"

     $XMLPath = $XMLPath.Replace(".","/")
     $Return = @()
     
   # =============================================================================================================================================
   # At least the application executable is an authorized file.
   # =============================================================================================================================================
   
     if($CommandLine)
      {
       $Return += "$CommandLine    (Process: *)"
      }

   # =============================================================================================================================================
   # The authorized files are stored in 
   # respowerfuse.buildingblock.application.appguard.authorizedfiles.authfile
   # =============================================================================================================================================
   
     $AuthFilesDetails = @($BuildingBlockDetails | Select-Xml -XPath "/$XMLPath").Node
            
     forEach ($AuthFilesDetail in $AuthFilesDetails)
      {
       $enabled = $AuthFilesDetail | Select-Object -ExpandProperty 'enabled'
       if($enabled -eq "yes")
        {
         $authorizedfile = $AuthFilesDetail | Select-Object -ExpandProperty 'authorizedfile'
         Add-EntryToLogFile -Entry "  -> authorizedfile:   $authorizedfile"
         $process        = $AuthFilesDetail | Select-Object -ExpandProperty 'process'
         Add-EntryToLogFile -Entry "  -> process:          $process"
         $Rights         = $AuthFilesDetail | Select-Object -ExpandProperty 'operation'
         Switch ($Rights)
          {
           "r"   {$Rights = "Only Read"            ; Break}
           "rx"  {$Rights = "Read Execute"         ; Break}
           "rw"  {$Rights = "Read Write"           ; Break}
           "rxw" {$Rights = "Read Write Execute"   ; Break}
          }
         Add-EntryToLogFile -Entry "  -> Operation rights: $Rights"
         $Return += "`n$authorizedfile   (Process: $process with rights: $Rights)"
        }
      }

     Add-EntryToLogFile -Entry "(Function: Get-XMLDetailsForAuthorizedFiles) The return value for $XMLPath is $Return." 

     Return $Return
   }

  Function Get-XMLDetailsForWorkspaces
   {

    <#
    .NOTES
    =============================================================================================================================================
    Created with:     Windows PowerShell ISE
    Created on:       26 April 2020
    Created by:       Willem-Jan Vroom
    Organization:     
    Functionname:     Get-XMLDetailsForWorkspaces
    =============================================================================================================================================
    .SYNOPSIS

    This function returns the authorized files.
    #>
   
    Param
      (
       [xml]    $BuildingBlockDetails,
       [string] $XMLPath_WorkspaceControl,
       [string] $XMLPath_Workspaces
      )
       
     Add-EntryToLogFile -Entry "--> In function: Get-XMLDetailsForWorkspaces"

     $XMLPath1 = $XMLPath_WorkspaceControl.Replace(".","/")
     $XMLPath2 = $XMLPath_Workspaces.Replace(".","/")
     $Return  = ""

   # =============================================================================================================================================
   # The workspaces GUID
   # respowerfuse.buildingblock.application.workspacecontrol
   # The name that belongs to the GUID is stored in
   # respowerfuse.buildingblock.workspaces
   # =============================================================================================================================================
 
     $WorkspaceGUIDs = @($BuildingBlockDetails | Select-Xml -XPath "/$XMLPath1/workspace").Node."#text"
     $Workspaces     = @($BuildingBlockDetails | Select-Xml -XPath "/$XMLPath2/workspace").Node
     Foreach ($WorkspaceGUID in $WorkspaceGUIDs)
      {
       ForEach ($Workspace in $Workspaces)
        {
         if($WorkspaceGUID -eq $Workspace.guid -and ($workspace.enabled -eq "yes"))
          {
           if(-not($Return))
            {
             $authorizedWorkspace = $Workspace | Select-Object -ExpandProperty 'name'
             Add-EntryToLogFile -Entry "  -> authorized workspace:  $authorizedWorkspace" 
             $Return = "$authorizedWorkspace"
            }
             else
            {
             $authorizedWorkspace = $Workspace | Select-Object -ExpandProperty 'name'
             Add-EntryToLogFile -Entry "  -> authorized workspace:  $authorizedWorkspace" 
             $Return += "`n$authorizedWorkspace"
            }

          }
        }       
      
      }

     Add-EntryToLogFile -Entry "(Function: Get-XMLDetailsForWorkspaces) The return value for $XMLPath is $Return." 
     Return $Return
   }

  Function Get-XMLDetailsForPowerZones
   {

    <#
    .NOTES
    =============================================================================================================================================
    Created with:     Windows PowerShell ISE
    Created on:       26 April 2020
    Created by:       Willem-Jan Vroom
    Organization:     
    Functionname:     Get-XMLDetailsForPowerZones
    =============================================================================================================================================
    .SYNOPSIS

    This function returns the authorized files.
    #>
   
    Param
      (
       [xml]    $BuildingBlockDetails,
       [string] $XMLPath
      )
       
     Add-EntryToLogFile -Entry "--> In function: Get-XMLDetailsForPowerZones"
     $XMLPath = $XMLPath.Replace(".","/")
     $Return = ""

   # =============================================================================================================================================
   # The powerzones are stored in 
   # respowerfuse.buildingblock.application.powerzones.powerzone
   # =============================================================================================================================================

     $PowerZones = @($BuildingBlockDetails | Select-Xml -XPath "/$XMLPath").Node."#text"
       
     forEach ($PowerZone in $PowerZones)
      {
       if(-not($Return))
        {
         Add-EntryToLogFile -Entry "  -> authorized powerzone:  $PowerZone" 
         $Return = $PowerZone
        }
         else
        {
         Add-EntryToLogFile -Entry "  -> authorized powerzone:  $PowerZone" 
         $Return += "`n$PowerZone"
       }
      }

     Add-EntryToLogFile -Entry "(Function: Get-XMLDetailsForPowerZones) The return value for $XMLPath is $Return."
     Return $Return
   }

  Function Get-XMLDetailsForFileTypes
   {

    <#
    .NOTES
    =============================================================================================================================================
    Created with:     Windows PowerShell ISE
    Created on:       18 August 2020
    Created by:       Willem-Jan Vroom
    Organization:     
    Functionname:     Get-XMLDetailsForFileTypes
    =============================================================================================================================================
    .SYNOPSIS

    This function finds all the File Associations (File Types) in a building block.
    #>
   
    Param
      (
       [xml]    $BuildingBlockDetails,
       [string] $XMLPath
      )

     $XMLPath = $XMLPath.Replace(".","/")
     $Return  = @()

     $Associations  = @($BuildingBlockDetails | Select-Xml -XPath "/$XMLPath").Node
     Add-EntryToLogFile -Entry "--> In function: Get-XMLDetailsForFileTypes"
     
     if ($Associations)
      {
       ForEach ($Association in $Associations)
        {
         if (($Association.Enabled -eq "yes") -and ($($Return -Split "`n") -notcontains $($Association.Extension)))        
          {
           if(-not($Return))
            {
             $Return = $($Association.Extension)
            }
             else
            {
             $Return += "`n$($Association.Extension)"
            }
          }
        }
      }
     Add-EntryToLogFile -Entry "(Function: Get-XMLDetailsForFileTypes) The return value for $XMLPath is $Return."
     Return $Return
   }

  Function Find-InArry
   {
    
    <#
    .NOTES
    =============================================================================================================================================
    Created with:     Windows PowerShell ISE
    Created on:       17-October-2018 Updated on 03-Aug-2020
    Created by:       Willem-Jan Vroom
    Organization:     
    Functionname:     Find-InArry
    =============================================================================================================================================
    .SYNOPSIS

    This function checks two arrays for content. 
    Based on https://stackoverflow.com/questions/25384346/find-common-items-in-two-powershell-arrays

    #>

    Param
     (
      [String[]] $SearchInArray,
      [String[]] $LookForInArray,
      [string]   $Suffix = "",
      [Switch]   $ExactMatch 
     )

    $tmpArray = @()
    
    ForEach ($objSearchInArray in $SearchInArray)
     {
      ForEach ($objLookForInArray in $LookForInArray)
       {
        $Condition = "*$($objLookForInArray)*"
        if($ExactMatch)
         {
          $Condition = "$($objLookForInArray)"
         }
        if($objSearchInArray -like "$Condition")
         {
          $tmpArray += $objLookForInArray             
          if(-not($Suffix))
           {
            $Entry    = "$objLookForInArray has been found in $objSearchInArray."
           }
            else
           {
            $Entry    = "$Suffix $objLookForInArray has been found in $objSearchInArray."
           }
          Add-EntryToLogFile -Entry $Entry
         }
       }
     } 
    Return $tmpArray
   }

  Function FindInfoInBuildingBlock
   {

    <#
    .NOTES
    =============================================================================================================================================
    Created with:     Windows PowerShell ISE
    Created on:       26 April 2020
    Created by:       Willem-Jan Vroom
    Organization:     
    Functionname:     FindInfoInBuildingBlock
    =============================================================================================================================================
    .SYNOPSIS

    This function finds all the information in the building block.
    #>

    Param
     (
      [xml]    $BuildingBlockDetails,
      [String] $Filename
     )

     $Commandline                         = ""
     $numApplications                     = $BuildingBlockDetails.respowerfuse.buildingblock.application.Count
     if(-not($numApplications))
      {
       $numApplications = 1
      }
     
     # =============================================================================================================================================
     # It is checked if there are somewhere linked actions or linked user preferences in the building block. 
     # If so the variable $BuildingBlockContainsLinkedApplications or $BuildingBlockContainsLinkedUserPreferences is set
     # to true. Then each application is checked for linked actions. If a linked action is found, it is processed.
     # If there are no linked actions anywhere then all the applications are processed.
     # =============================================================================================================================================
         
     $BuildingBlockContainsLinkedStuff = $false
     if(($BuildingBlockDetails.respowerfuse.buildingblock.application.powerlaunch.linked_actions.linked_to_application) -or ($BuildingBlockDetails.respowerfuse.buildingblock.application.userpreference_settings.linkeduserpreference))
      {
       $BuildingBlockContainsLinkedStuff = $true
      }
      
     Add-EntryToLogFile -Entry "Number of applications:                           $numApplications"
     Add-EntryToLogFile -Entry "Building block contains linked stuff:             $BuildingBlockContainsLinkedStuff"
                
     for($ApplicationCounter = 0; $ApplicationCounter -lt $numApplications; $ApplicationCounter++)
      {
       if($numApplications -eq 1)
        {
         $ApplicationXML                     = $BuildingBlockDetails.respowerfuse.buildingblock.application
        }
         else
        {
         $ApplicationXML                     = $BuildingBlockDetails.respowerfuse.buildingblock.application.Item($ApplicationCounter)
        }
       
     $ApplicationContainsLinkedActions = $false
     If($ApplicationXML.powerlaunch.linked_actions.linked_to_application)
      {
       $ApplicationContainsLinkedActions = $true
      }

     $ApplicationContainslinkedUserPreference = $false
     If($ApplicationXML.userpreference_settings.linkeduserpreference)
      {
       $ApplicationContainslinkedUserPreference = $true
      }
   
     $Condition1 = (-not $BuildingBlockContainsLinkedStuff)
     $Condition2 = ($BuildingBlockContainsLinkedStuff -and ($ApplicationContainsLinkedActions -or $ApplicationContainslinkedUserPreference))

     if ($Condition1 -or $Condition2)
      {         
       Add-EntryToLogFile -Entry "Application contains linked applications:         $ApplicationContainsLinkedActions"
       Add-EntryToLogFile -Entry "Application contains linked user preferences:     $ApplicationContainslinkedUserPreference"       
       Add-EntryToLogFile -Entry "The following conditions are met:"
       if($Condition1)
        {  
         Add-EntryToLogFile -Entry "CONDITION: The building block does not contain any linked stuff."
        }
       if($Condition2)
        {
         Add-EntryToLogFile -Entry "CONDITION: The building block contains linked actions and ..."
         if($ApplicationContainsLinkedActions)
          {
           Add-EntryToLogFile -Entry " ... the application contains linked actions."
          }
         if($ApplicationContainslinkedUserPreference)
          {
           Add-EntryToLogFile -Entry " ... the application contains linked user settings."
          }
        }

       $appid                               = $ApplicationXML.appid
       $Title                               = $ApplicationXML.configuration.title
       $StartMenu                           = $ApplicationXML.configuration.menu
       $Description                         = $ApplicationXML.configuration.description
       $Commandline                         = $ApplicationXML.configuration.commandline
       $accesstype                          = $ApplicationXML.accesscontrol.accesstype
       $AccessMode                          = $ApplicationXML.accesscontrol.access_mode
       $Parameters                          = $ApplicationXML.configuration.parameters
       $tmpCounter                          = $ApplicationCounter+1
       Switch ($accesstype)
            {
             "group"     {$GroupList                           = @(Get-XMLDetailsForAccessInfo -BuildingBlockDetails $BuildingBlockDetails -XMLPath "respowerfuse.buildingblock.application[$tmpCounter].accesscontrol" -accessmode $AccessMode -accesstype $accesstype)
                          $accesstype = "Users and groups"
                          break
                         }
             "delegated" {$GroupList                           = @(Get-XMLDetailsForAccessInfo -BuildingBlockDetails $BuildingBlockDetails -XMLPath "respowerfuse.buildingblock.application[$tmpCounter].accesscontrol" -accessmode $AccessMode -accesstype $accesstype)
                          $accesstype = "Controlled by application manager(s)"
                          break
                         }
             "ou"        {$accesstype = "OU membership"
                          break
                         }
             "all"       {$accesstype = "All users"
                          break
                         }
             "secrole"   {$accesstype = "Administrative roles"
                          break
                         }
             "orchestra" {$accesstype = "Identity Director Service"
                          break
                         }
              default    {$accesstype = "An invalid access type has been discovered."}
            }

       $PowerZones        = @(Get-XMLDetailsForPowerZones  -BuildingBlockDetails $BuildingBlockDetails -XMLPath "respowerfuse.buildingblock.application[$tmpCounter].powerzones.powerzone")
       $Workspaces        = @(Get-XMLDetailsForWorkspaces  -BuildingBlockDetails $BuildingBlockDetails -XMLPath_WorkspaceControl "respowerfuse.buildingblock.application[$tmpCounter].workspacecontrol" -XMLPath_Workspaces "respowerfuse.buildingblock.workspaces")
       $FileTypes         = @(Get-XMLDetailsForFileTypes   -BuildingBlockDetails $BuildingBlockDetails -XMLPath "respowerfuse.buildingblock.application[$tmpCounter].instantfileassociations.association")
         
       # =============================================================================================================================================
       # Check if LookFor is used. In that case check the title, commandline, groups, locations and containers.
       # =============================================================================================================================================
 
       $bolInAppID     = $false
       $boltitle       = $false
       $bolCommandLine = $false
       $bolParameter   = $false
       $bolFileTypes   = $false
       $bolGroupOrUser = $false
       $bolLocations   = $false
       $bolContainers  = $false
       $Remark         = ""

       if($Global:gblLookFor)
        {
         
         # Check the AppID
         if($appid)
          {
           $Suffix = "[AppID]"
           $Results = Find-InArry -SearchInArray $appID -LookForInArray $Global:gblInAppID -Suffix $Suffix -ExactMatch
           ForEach ($Result in $Results)
            {
             $bolInAppID = $true
             $Remark     = "$Suffix $Result"       
            }
          }

         # Check the title
         if($Title)
          {
           $Suffix = "[Title]"
           $Results = Find-InArry -SearchInArray $Title -LookForInArray $Global:gblInTitle -Suffix $Suffix 
           ForEach ($Result in $Results)
            {
             $boltitle = $true
             $Remark = "$Suffix $Result"       
            }
          }

         # Check the command line
         if($Commandline)
          {
           $Suffix = "[Command]"
           $Results = Find-InArry -SearchInArray $Commandline -LookForInArray $Global:gblInCommandLine -Suffix $Suffix 
           ForEach ($Result in $Results)
            {
             $bolCommandLine = $true
             if(-not ($Remark))
              {
               $Remark         = "$Suffix $Result"
              }
               else
              {
               $Remark        += "`n$Suffix $Result"
              }
            }
          }

         # Check the parameter line
         if($Parameters)
          {
           $Suffix  = "[Parameter]"  
           $Results = Find-InArry -SearchInArray $Parameters -LookForInArray $Global:gblInParameter -Suffix $Suffix
           ForEach ($Result in $Results)
            {
             $bolParameter = $true
             if(-not ($Remark))
              {
               $Remark         = "$Suffix $Result"
              }
               else
              {
               $Remark        += "`n$Suffix $Result"
              }
            }
          }

         # Check the file types
         if ($FileTypes)
          {
           $Suffix  = "[File types]"
           $Results = Find-InArry -SearchInArray $FileTypes -LookForInArray $Global:gblInFileTypes -Suffix $Suffix
           ForEach ($Result in $Results)
            {
             $bolFileTypes = $true
             if(-not ($Remark))
              {
               $Remark         = "$Suffix $Result"
              }
               else
              {
               $Remark        += "`n$Suffix $Result"
              }
            }
          }

         # Check the group or user
         if($accesstype = "Users and groups")
          {           
           $Suffix  = "[GroupOrUser]"
           $Results = Find-InArry -SearchInArray $($GroupList -split "`n") -LookForInArray $Global:gblInGroupOrUser -Suffix $Suffix
           ForEach ($Result in $Results)
            {
             $bolGroupOrUser = $true
             if(-not($Remark))
              {
               $Remark = "$Suffix $Result"
              }
               else
              {
               $Remark += "`n$Suffix $Result"
              }
            }
          }

         # Locations (also called PowerZones)
         if($PowerZones)
          {
           $Suffix  = "[Locations]"
           $Results = Find-InArry -SearchInArray $($PowerZones -split "`n") -LookForInArray $Global:gblInLocations -Suffix $Suffix -ExactMatch:$Global:gblExactMatchLocation
           ForEach ($Result in $Results)
            {
             $bolLocations   = $true
             if(-not($Remark))
              {
               $Remark = "$Suffix $Result"
              }
               else
              {
               $Remark += "`n$Suffix $Result"
              }
            }
          }

         # Containers (also called Workspaces)
         if($Workspaces)
          { 
           $Suffix  = "[Containers]"
           $Results = Find-InArry -SearchInArray $($Workspaces -split "`n") -LookForInArray $Global:gblInContainers -Suffix $Suffix -ExactMatch:$Global:gblExactMatchContainer
           ForEach ($Result in $Results)
            {
             $bolContainers = $true
             if(-not($Remark))
              {
               $Remark = "$Suffix $Result"
              }
               else
              {
               $Remark += "`n$Suffix $Result"
              }
            }
          }

         # =============================================================================================================================================
         # Check if all the conditions are met.
         # =============================================================================================================================================

         $bolAllConditionsAreMet = $true

         if($Global:gblInAppID)
          {
           if($bolInAppID)
            {
             $bolAllConditionsAreMet = $true
             Add-EntryToLogFile "--> InAppID:    All Conditions Are Met has been set to true."
            }
             else
            {
             $bolAllConditionsAreMet = $false
             Add-EntryToLogFile "--> InAppID:    All Conditions Are Met has been set to false."
            }
          }
         
         if($bolAllConditionsAreMet)
          {
           if($Global:gblInTitle)
            {
             if($boltitle)
              {
               $bolAllConditionsAreMet = $true
               Add-EntryToLogFile "--> InTitle:    All Conditions Are Met has been set to true."
              }
               else
              {
               $bolAllConditionsAreMet = $false
               Add-EntryToLogFile "--> InTitle:    All Conditions Are Met has been set to false."
              }
            }
          }

          if($bolAllConditionsAreMet)
           {
            if($Global:gblInCommandLine)
             {
              if($bolCommandLine)
               {
                $bolAllConditionsAreMet = $true
                Add-EntryToLogFile "--> InCommandline:    All Conditions Are Met has been set to true."
               }
                else
               {
                $bolAllConditionsAreMet = $false
                Add-EntryToLogFile "--> InCommandline:    All Conditions Are Met has been set to false."
               }
             }
           }

          if($bolAllConditionsAreMet)
           {
            if($Global:gblInParameter)
             {
              if($bolParameter)
               {
                $bolAllConditionsAreMet = $true
                Add-EntryToLogFile "--> Parameter:    All Conditions Are Met has been set to true."
               }
                else
               {
                $bolAllConditionsAreMet = $false
                Add-EntryToLogFile "--> Parameter:    All Conditions Are Met has been set to false."
               }
             }
           }

          if($bolAllConditionsAreMet)
           {
            if($Global:gblInFileTypes)
             {
              if($bolFileTypes)
               {
                $bolAllConditionsAreMet = $true
                Add-EntryToLogFile "--> Parameter:    All Conditions Are Met has been set to true."
               }
                else
               {
                $bolAllConditionsAreMet = $false
                Add-EntryToLogFile "--> Parameter:    All Conditions Are Met has been set to false."
               }
             }
           }

          if($bolAllConditionsAreMet)
           {
            if($Global:gblInGroupOrUser)
             {
              if($bolGroupOrUser)
               {
                $bolAllConditionsAreMet = $true
                Add-EntryToLogFile "--> GroupOrUser:    All Conditions Are Met has been set to true."
               }
                else
               {
                $bolAllConditionsAreMet = $false
                Add-EntryToLogFile "--> GroupOrUser:    All Conditions Are Met has been set to false."
               }
             }
           }

          if($bolAllConditionsAreMet)
           {
            if($Global:gblInLocations)
             {
              if($bolLocations)
               {
                $bolAllConditionsAreMet = $true
                Add-EntryToLogFile "--> Locations:    All Conditions Are Met has been set to true."
               }
                else
               {
                $bolAllConditionsAreMet = $false
                Add-EntryToLogFile "--> Locations:    All Conditions Are Met has been set to false."
               }
             }
           }

          if($bolAllConditionsAreMet)
           {
            if($Global:gblInContainers)
             {
              if($bolContainers)
               {
                $bolAllConditionsAreMet = $true
                Add-EntryToLogFile "--> Containers:    All Conditions Are Met has been set to true."
               }
                else
               {
                $bolAllConditionsAreMet = $false
                Add-EntryToLogFile "--> Containers:    All Conditions Are Met has been set to false."
               }
             }
           }

          Add-EntryToLogFile "After containers: All Conditions are met: $bolAllConditionsAreMet"

         }
         
         if((-not($Global:gblLookFor)) -or ($bolAllConditionsAreMet))
          {
           $Workingdir                          = $ApplicationXML.configuration.workingdir           
           $appv5packagemode                    = $ApplicationXML.configuration.appv5packagemode
           $appv5packagefile                    = $ApplicationXML.configuration.appv5packagefile
           $appv5deploymentconfigurationfile    = $ApplicationXML.configuration.appv5deploymentconfigurationfile
           $appv5userconfigurationfile          = $ApplicationXML.configuration.appv5userconfigurationfile
           $appv5packageupdate                  = $ApplicationXML.configuration.appv5packageupdate
           $appv5packageroot                    = $ApplicationXML.configuration.appv5packageroot
           $administrativenote                  = $ApplicationXML.configuration.administrativenote 
           $unmanagedshortcuts                  = $ApplicationXML.configuration.unmanagedshortcuts
           $createmenushortcut                  = $ApplicationXML.configuration.createmenushortcut
           $allowmultipleshortcuts              = $ApplicationXML.configuration.allowmultipleshortcuts

           $Enabled                             = $ApplicationXML.settings.enabled
           $hidefrommenu                        = $ApplicationXML.settings.hidefrommenu
           $checkappexists                      = $ApplicationXML.settings.checkappexists
           $checkfileexists                     = $ApplicationXML.settings.checkfileexists
                  
           $LearningMode                        = $ApplicationXML.appguard.learning     

           $AppGuard                            = Get-XMLDetailsForAuthorizedFiles  -BuildingBlockDetails $BuildingBlockDetails -XMLPath "respowerfuse.buildingblock.application[$tmpCounter].appguard.authorizedfiles.authfile" -CommandLine $Commandline
                       
           $ApplicationContainsLinkedActions1   = "no"
           $ApplicationContainsLinkedSettings1   = "no" 

           If($ApplicationContainsLinkedActions)
            {
             $ApplicationContainsLinkedActions1 = "yes"
            }
            
           if($ApplicationContainslinkedUserPreference)
            {
             $ApplicationContainsLinkedSettings1 = "yes"
            }
                                
           Add-EntryToResultsFile  -XMLFileName                       $Filename                           `
                                   -StartMenu                         $StartMenu                          `
                                   -appid                             $appid                              `
                                   -Title                             $Title                              `
                                   -Description                       $Description                        `
                                   -Commandline                       $Commandline                        `
                                   -Workingdir                        $Workingdir                         `
                                   -Parameters                        $Parameters                         `
                                   -appv5packagemode                  $appv5packagemode                   `
                                   -appv5packagefile                  $appv5packagefile                   `
                                   -appv5deploymentconfigurationfile  $appv5deploymentconfigurationfile   `
                                   -appv5packageupdate                $appv5packageupdate                 `
                                   -appv5userconfigurationfile        $appv5userconfigurationfile         `
                                   -appv5packageroot                  $appv5packageroot                   `
                                   -administrativenote                $administrativenote                 `
                                   -unmanagedshortcuts                $unmanagedshortcuts                 `
                                   -createmenushortcut                $createmenushortcut                 `
                                   -allowmultipleshortcuts            $allowmultipleshortcuts             `
                                   -Enabled                           $Enabled                            `
                                   -hidefrommenu                      $hidefrommenu                       `
                                   -checkappexists                    $checkappexists                     `
                                   -checkfileexists                   $checkfileexists                    `
                                   -FileTypesInTable                  $FileTypes                          `
                                   -accesstype                        $accesstype                         `
                                   -GroupList                         $GroupList                          `
                                   -PowerZones                        $PowerZones                         `
                                   -Workspaces                        $Workspaces                         `
                                   -LearningMode                      $LearningMode                       `
                                   -AppGuard                          $AppGuard                           `
                                   -ApplicationContainsLinkedActions  $ApplicationContainsLinkedActions1  `
                                   -ApplicationContainsLinkedSettings $ApplicationContainsLinkedSettings1 `
                                   -Remark                            $Remark                             `
                                   -NumberOfApplications              $numApplications
           if($Global:gblTo -and $Global:gblCopyFiles)
            {
             Copy-Item -Path $($Global:gblBuildingBlockFileName -replace ".xml",".*") -Destination $Global:gblTo -Force
             Add-EntryToLogFile "The file $($Global:gblBuildingBlockFileName) has been copied to $($Global:gblTo)."
            }
          }
           else
          {
           Add-EntryToLogFile -Entry "The search-item has not been found in the application $Title.`n"
          }                     
        }
      }
   }

  Function Get-FolderFromButton
   {
    <#
    .NOTES
    =============================================================================================================================================
    Created with:     Windows PowerShell ISE
    Created on:       26-January-2021 / Updated 09-February-2021
    Created by:       Willem-Jan Vroom
    Organization:     
    Functionname:     Get-FolderFromButton
    =============================================================================================================================================
    .SYNOPSIS

    You can browse to a folder when clicked on the 'Browse' button.
    #>

    Param
    (
     [String] $InitialDirectory,
     [String] $Description,
     [Switch] $AllowNewFolder
    )

    $Folder                         = New-Object System.Windows.Forms.FolderBrowserDialog
    $Folder.ShowNewFolderButton     = $AllowNewFolder
    $Folder.SelectedPath            = $InitialDirectory
    $Folder.Description             = $Description
    [void]$Folder.ShowDialog()
    Return $Folder.SelectedPath
   }

  Function Convert-TextFromTextBoxToArray
   {
    <#
    .NOTES
    =============================================================================================================================================
    Created with:     Windows PowerShell ISE
    Created on:       01-Februari-2021
    Created by:       Willem-Jan Vroom
    Organization:     
    Functionname:     Convert-TextFromTextBoxToArray
    =============================================================================================================================================
    .SYNOPSIS

    Convert the text from an text box to an array.
    #>

    Param
    (
     [String] $Text
    )

    $TextNew   = $Text.Replace(",",[environment]::NewLine)
    $TempValue = ($TextNew.Trim()).split([environment]::NewLine,[System.StringSplitOptions]"RemoveEmptyEntries")
    if($Text)
     {
      Add-EntryToLogFile -Entry "The text '$Text' has been converted to '$TempValue'"
     }
    Return $TempValue  
   }
  
  Function Convert-ArrayToTextForTextBox
   {
    <#
    .NOTES
    =============================================================================================================================================
    Created with:     Windows PowerShell ISE
    Created on:       01-Februari-2021
    Created by:       Willem-Jan Vroom
    Organization:     
    Functionname:     Convert-ArrayToTextForTextBox
    =============================================================================================================================================
    .SYNOPSIS

    Convert an array to a text for a text box.
    #>

    Param
    (
     [String[]] $ArrayToConvert
    )
   
    $TempValue  = ""
    $valCounter = 0

    ForEach ($Object in $ArrayToConvert)
     {
      if(-not($TempValue))
       {
        $TempValue = $ArrayToConvert[$valCounter]
        $valCounter ++
       }
        else
       {
        $TempValue += [Environment]::NewLine + $ArrayToConvert[$valCounter]
        $valCounter ++
       }
     }
    Return $TempValue
   }

  Function Process-AllTheBuildingBlocks
   {

    <#
    .NOTES
    =============================================================================================================================================
    Created with:     Windows PowerShell ISE
    Created on:       02-February-2021
    Created by:       Willem-Jan Vroom
    Organization:     
    Functionname:     Process-AllTheBuildingBlocks
    =============================================================================================================================================
    .SYNOPSIS

    This function processes all the Building Block XML Files in the given folder. 

    #>

    param
     (
      [Switch] $IncludeTheSubFolders,
      [Switch] $GUI
     )

    if($Global:gblInAppID -or $Global:gblInTitle -or $Global:gblInCommandLine -or $Global:gblInParameter -or $Global:gblInFileTypes -or $Global:gblInGroupOrUser -or $Global:gblInLocations -or $Global:gblInContainers)
     {
      Add-EntryToLogFile -Entry  = "LookFor has been added."
      $Global:gblLookFor  = $True
     }
      else
     {
      $Global:gblLookFor = $False
     }
    
    $BuildingBlockFileNames = @(Get-ChildItem -Path $Global:gblDirectory -Filter *.xml -Recurse:$Global:gblIncludeSubFolders | Sort-Object -Property FullName)
    
  # =============================================================================================================================================
  # Go through all the xml files.
  # =============================================================================================================================================

    $TotalBuildingBlocks = $BuildingBlockFileNames.Count
    $valCounter          = 1
    if ($GUI)
     {
      $ProgressBar.Visible = $True
     }
     
    ForEach ($BuildingBlockFileName in $BuildingBlockFileNames)
     {
      [int]$Percentage = $valCounter / $TotalBuildingBlocks * 100
      if ($GUI)
       {
        $ProgressBar.Value = $Percentage 
       }
      if(-not $Global:gblNoProgressBar -and $Global:gblSilent)
       {
        [int]$Percentage = $valCounter / $TotalBuildingBlocks * 100
        Write-Progress -Id 1 -Activity "Processing all the exported building blocks. Building block $valCounter of $TotalBuildingBlocks buildingblocks ($($Percentage)%)" -Status "Processing building block $BuildingBlockFileName" -PercentComplete $Percentage
       }
      if(test-path($BuildingBlockFileName.FullName))
       {
        $Global:gblBuildingBlockFileName = $BuildingBlockFileName.FullName
        Add-EntryToLogFile -Entry "Found: $Global:gblBuildingBlockFileName"
        Try
         {
          $BuildingBlockData = [xml](Get-Content -Path $Global:gblBuildingBlockFileName)
          if(($BuildingBlockData.respowerfuse.buildingblock.application.guid) -and (CheckXMLFile -XMLFile $Global:gblBuildingBlockFileName))
           {
            Add-EntryToLogFile -Entry "Processing: $Global:gblBuildingBlockFileName"
            FindInfoInBuildingBlock -BuildingBlockDetails $BuildingBlockData -Filename $Global:gblBuildingBlockFileName
           }
            else
           {
            Add-EntryToLogFile -Entry "It seems that $Global:gblBuildingBlockFileName is not a real Ivanti application building block.`nThus skipping.`n"
           }
         }
          Catch
         {
          Add-EntryToLogFile -Entry ""
          Add-EntryToLogFile -Entry "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
          Add-EntryToLogFile -Entry ""
          Add-EntryToLogFile -Entry "There is an error in the xml file $Global:gblBuildingBlockFileName."
          Add-EntryToLogFile -Entry ""
          Add-EntryToLogFile -Entry "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
          Add-EntryToLogFile -Entry ""         
         }
       }
      $valCounter++
     }
   }

  Function Write-HTMLFile
   {

    <#
    .NOTES
    =============================================================================================================================================
    Created with:     Windows PowerShell ISE
    Created on:       02-February-2021
    Created by:       Willem-Jan Vroom
    Organization:     
    Functionname:     Process-AllTheBuildingBlocks
    =============================================================================================================================================
    .SYNOPSIS

    This function processes all the Building Block XML Files in the given folder. 

    #>

    param
     (
      [String] $HTMLFileToWrite
     )

  # =============================================================================================================================================
  # Define the CSS file.
  # =============================================================================================================================================
    
    $Header      = ""
    $CSS         = "<style type=$([char]34)text/css$([char]34)>`n"
    $CSS        += "table              {`n"
    $CSS        += "                    font-size:      16px;`n"
    $CSS        += "                    border:         1px solid #395870;`n"
    $CSS        += "                    font-family:    Arial, Helvetica, sans-serif;`n"
    $CSS        += "                   }`n`n"
    $CSS        += "td                 {`n"
    $CSS        += "                    padding:        5px;`n"
    $CSS        += "                    margin:         0px;`n"
    $CSS        += "                    border:         1px solid #395870;`n"
    $CSS        += "                    max-width:      700px;`n"
    $CSS        += "                    vertical-align: top;`n"
    $CSS        += "                   }`n`n"
    $CSS        += "th                 {`n"
    $CSS        += "                    background:     #395870;`n"
    $CSS        += "                    background:     linear-gradient(#49708f, #293f50);`n"
    $CSS        += "                    color:          #fff;`n"
    $CSS        += "                    font-size:      14px;`n"
    $CSS        += "                    padding:        10px 15px;`n"
    $CSS        += "                    vertical-align: top;`n"
    $CSS        += "                    border:         1px solid #395870;`n"
    $CSS        += "                   }`n`n"
    $CSS        += "tr                 {`n"
    $CSS        += "                    width:          1000px;`n"
    $CSS        += "                   }`n`n"
    $CSS        += "h1                 {`n"
    $CSS        += "                    font-family:    Arial, Helvetica, sans-serif;`n"
    $CSS        += "                    color:          #e68a00;`n"
    $CSS        += "                    font-size:      28px;`n"
    $CSS        += "                    text-align:     center;`n"
    $CSS        += "                   }`n`n"
    $CSS        += "h2                 {`n"
    $CSS        += "                    font-family:    Arial, Helvetica, sans-serif;`n"
    $CSS        += "                    color:          #000099;`n"
    $CSS        += "                    font-size:      16px;`n"
    $CSS        += "                    text-align:     center;`n"
    $CSS        += "                   }`n`n"
    $CSS        += "#Cred              {`n"
    $CSS        += "                    font-family:    Arial, Helvetica, sans-serif;`n"
    $CSS        += "                    color:          #0000ff;`n"
    $CSS        += "                    font-size:      12px;`n"
    $CSS        += "                    text-align:     left;`n"
    $CSS        += "                   }`n`n"
    $CSS        += "tr:nth-child(even) {`n"
    $CSS        += "                    background:     #CCC;`n"
    $CSS        += "                   }`n`n"
    $CSS        += "tr:nth-child(odd)  {`n"
    $CSS        += "                    background:     #FFF;`n"
    $CSS        += "                   }`n`n"
    $CSS        += ".ReadExecute       {`n"
    $CSS        += "                    color: green;`n"
    $CSS        += "                   }`n`n"
    $CSS        += ".ReadWrite         {`n"
    $CSS        += "                    color: red;`n"
    $CSS        += "                   }`n`n"
    $CSS        += ".Read              {`n"
    $CSS        += "                    color: green;`n"
    $CSS        += "                   }`n`n"
    $CSS        += "</style>"
    $CSS      += ""
    
  # =============================================================================================================================================
  # Replace the `n with <br> in various columns. So there is a proper table layout.
  # Do some cleanup afterwards.
  # =============================================================================================================================================
  
    If($Global:gblSummary)
     {
      $Global:gblarrTable = $Global:gblarrTable | Select-Object -Property "XML File Name","Start Menu location","Properties - General - ID","Properties - General - Title","Properties - General - Description","Properties - General - Commandline","Properties - General - Parameters","Properties - Settings - Application is enabled","Properties - FileTypes","Access Control - Identy - Type","Access Control - Identy - Selected users and/or groups","Access Control - Location and devices","Access Control - Workspace containers","Remark"
     }


    ForEach ($Record in $Global:gblarrTable)
     {
      if($Record."Properties - FileTypes")                                  
       {$Record."Properties - FileTypes"                                 = $Record."Properties - FileTypes"                                 -replace "`n","<br>"}
      if($Record."Security - Authorized Files - Authorized file")           
       {$Record."Security - Authorized Files - Authorized file"          = $Record."Security - Authorized Files - Authorized file"          -replace "`n","<br><br>"}
      if($Record."Access Control - Identy - Selected users and/or groups")  
       {$Record."Access Control - Identy - Selected users and/or groups" = $Record."Access Control - Identy - Selected users and/or groups" -Replace "`n","<br>"}
      if($Record."Access Control - Location and devices")                   
       {$Record."Access Control - Location and devices"                  = $Record."Access Control - Location and devices"                  -Replace "`n","<br>"}
      if($Record."Access Control - Workspace containers")                   
       {$Record."Access Control - Workspace containers"                  = $Record."Access Control - Workspace containers"                  -Replace "`n","<br>"}
      if($Record."Remark") 
       {$Record."Remark"                                                 = $Record."Remark"                                                 -replace "`n","<br>"}
     }
       
    $HTMLTable   = $Global:gblarrTable | Sort-Object -Property "Start Menu location","Properties - General - Title","XML File Name","Properties - General - ID" | ConvertTo-Html -Fragment -PreContent "<h2>Table</h2>"
    $HTMLTable   = [System.Web.HttpUtility]::HtmlDecode($HTMLTable)

    $HTMLTable   = $HTMLTable -replace "Only Read","<span class=$([char]34)Read$([char]34)>Only Read</span>"
    $HTMLTable   = $HTMLTable -replace "Read Execute","<span class=$([char]34)ReadExecute$([char]34)>Read Execute</span>"
    $HTMLTable   = $HTMLTable -replace "Read Write Execute","<span class=$([char]34)ReadWrite$([char]34)>Read Write Execute</span>"
    $HTMLTable   = $HTMLTable -replace "Read Write","<span class=$([char]34)ReadWrite$([char]34)>Read Write</span>"
       
    $Title       = "<h1>Complete overview of the building blocks</h1>"
    $Body        = "$Title $HTMLTable"

    if($TableWithParameters.Count -gt 0)
     {
      $HTMLParameterstable = $TableWithParameters | ConvertTo-Html -Fragment
      $Body +="<br><h2>Used parameters for the script.</h2><br>$HTMLParameterstable"
     }



    $Timestamp   = (Get-Date -UFormat "%a %e %b %Y %X").ToString()
    $PostContent = "<p id=$([char]34)Cred$([char]34)>Creation Date: $Timestamp</p>"
    $Report      = ConvertTo-Html -Head $CSS -Body $Body -PostContent $PostContent 
    $Report | Out-File $HTMLFileToWrite

    Write-Host "The webpage '$HTMLFileToWrite' has been created." 
   }

  Function Set-Registry
   {
    <#
    .NOTES
    =============================================================================================================================================
    Created with:     Windows PowerShell ISE
    Created on:       13-February-2021
    Created by:       Willem-Jan Vroom
    Organization:     
    Functionname:     Set-Registry
    =============================================================================================================================================
    .SYNOPSIS

    This function sets a registry key
    
    #>

    param
     (
      [Parameter(Mandatory=$True) ] [String]$RegistryKey,
      [Parameter(Mandatory=$True) ] [String]$ValueName,
      [Parameter(Mandatory=$True) ] [String]$Value,
      [Parameter(Mandatory=$False)] [Switch]$Boolean,
      [Parameter(Mandatory=$False)] [Switch]$IsArray
     )

     # Check if the $Registrykey exists

     if(-not(test-path($RegistryKey)))
      {
       $Key    = $RegistryKey.Split(":")[1]
       $NewKey = $($RegistryKey.Split(":")[0]) + ":"
       foreach($Item in $($Key.Split("\")))
        {
         $NewKey += "\$Item"
         if(-not(test-path($NewKey)))
          {
           New-Item $NewKey -Force | Out-Null
           Add-EntryToLogFile "Created the registry key: $NewKey."
          }
        }

      }
     
     if($Boolean)
      {
       if($Value)
        { 
         New-ItemProperty -Path $RegistryKey -Name $ValueName -PropertyType DWord -Value 1 -Force | Out-Null
         Add-EntryToLogFile -Entry "Created in the hive $($RegistryKey):"
         Add-EntryToLogFile -Entry "  Created ValueName: $ValueName"
         Add-EntryToLogFile -Entry "          Type:      REG_DWORD"
         Add-EntryToLogFile -Entry "          Value:     1" 
        }
         else
        {
         New-ItemProperty -Path $RegistryKey -Name $ValueName -PropertyType DWord -Value 0 -Force | Out-Null
         Add-EntryToLogFile -Entry "Created in the hive $($RegistryKey):"
         Add-EntryToLogFile -Entry "  Created ValueName: $ValueName"
         Add-EntryToLogFile -Entry "          Type:      REG_DWORD"
         Add-EntryToLogFile -Entry "          Value:     0" 
        }
      }
       elseif($IsArray)
      {
       New-ItemProperty -Path $RegistryKey -Name $ValueName -PropertyType String -Value $($Value -join ",") -Force | Out-Null
       Add-EntryToLogFile -Entry "Created in the hive $($RegistryKey):"
       Add-EntryToLogFile -Entry "  Created ValueName: $ValueName"
       Add-EntryToLogFile -Entry "          Type:      REG_SZ"
       Add-EntryToLogFile -Entry "          Value:     $($Value -join ",")" 
      }
       else
      {
       New-ItemProperty -Path $RegistryKey -Name $ValueName -PropertyType String -Value $Value -Force | Out-Null
       Add-EntryToLogFile -Entry "Created in the hive $($RegistryKey):"
       Add-EntryToLogFile -Entry "  Created ValueName: $ValueName"
       Add-EntryToLogFile -Entry "          Type:      REG_SZ"
       Add-EntryToLogFile -Entry "          Value:     $Value" 
      }
   }

  Function Read-Registry
   {
    <#
    .NOTES
    =============================================================================================================================================
    Created with:     Windows PowerShell ISE
    Created on:       13-February-2021
    Created by:       Willem-Jan Vroom
    Organization:     
    Functionname:     Read-Registry
    =============================================================================================================================================
    .SYNOPSIS

    This function reads a registry key and returns the value
    
    #>

    param
     (
      [Parameter(Mandatory=$True)] [String]$RegistryKey,
      [Parameter(Mandatory=$True)] [String]$ValueName
     )

    if(Test-Path ($RegistryKey))
     {
      if([bool]((Get-ItemProperty -Path $RegistryKey).$ValueName))
       {
        $Value        = (Get-ItemProperty -Path $RegistryKey).$ValueName
        $PropertyType = (Get-Item $RegistryKey).GetValueKind($ValueName)
        Add-EntryToLogFile -Entry "Hive:          $RegistryKey"
        Add-EntryToLogFile -Entry "  - ValueName: $ValueName"
        Add-EntryToLogFile -Entry "  - Type:      $PropertyType"
        Add-EntryToLogFile -Entry "  - Value:     $Value"
        if($PropertyType -eq "String")
         {
          Return $Value
         }
          elseif($PropertyType -eq "DWord")
         {
          if($Value -eq 1)
           {
            Return $True
           }
            else
           {
            Return $False
           }
         }
       }
     }
     Return [string]::Empty
   }
    
  Function ReadAndSetSettings
   {

    <#
    .NOTES
    =============================================================================================================================================
    Created with:     Windows PowerShell ISE
    Created on:       13-February-2021
    Created by:       Willem-Jan Vroom
    Organization:     
    Functionname:     ReadAndSetSettings
    =============================================================================================================================================
    .SYNOPSIS

    This function reads or sets the settings in the registry.

    #>

    param
     (
      [Switch] $Set,
      [String] $RegistryKey
     )
  

    if($Set)
     {
      if(test-path ($RegistryKey))
       {
        Remove-Item -Path $RegistryKey -Force
       }
      if($Global:gblDirectory)          {Set-Registry -RegistryKey $RegistryKey -ValueName "Directory"                      -Value $Global:gblDirectory}
      if($Global:gblOutputDirectory)    {Set-Registry -RegistryKey $RegistryKey -ValueName "OutputDirectory"                -Value $Global:gblOutputDirectory}
      if($Global:gblLogPath)            {Set-Registry -RegistryKey $RegistryKey -ValueName "LogPath"                        -Value $Global:gblLogPath}
      if($Global:gblInAppID)            {Set-Registry -RegistryKey $RegistryKey -ValueName "InAppID"                        -Value $($Global:gblInAppID -join ",")}
      if($Global:gblInTitle)            {Set-Registry -RegistryKey $RegistryKey -ValueName "InTitle"                        -Value $($Global:gblInTitle -join ",")}
      if($Global:gblInCommandLine)      {Set-Registry -RegistryKey $RegistryKey -ValueName "InCommandLine"                  -Value $($Global:gblInCommandLine -join ",")}
      if($Global:gblInParameter)        {Set-Registry -RegistryKey $RegistryKey -ValueName "InParameter"                    -Value $($Global:gblInParameter -join ",")}
      if($Global:gblInFileTypes)        {Set-Registry -RegistryKey $RegistryKey -ValueName "InFileTypes"                    -Value $($Global:gblInFileTypes -join ",")}
      if($Global:gblInGroupOrUser)      {Set-Registry -RegistryKey $RegistryKey -ValueName "InGroupOrUser"                  -Value $($Global:gblInGroupOrUser -join ",")}
      if($Global:gblInLocations)        {Set-Registry -RegistryKey $RegistryKey -ValueName "InLocations"                    -Value $($Global:gblInLocations -join ",")}
      if($Global:gblInContainers)       {Set-Registry -RegistryKey $RegistryKey -ValueName "InContainers"                   -Value $($Global:gblInContainers -join ",")}
      if($Global:gblTo)                 {Set-Registry -RegistryKey $RegistryKey -ValueName "To"                             -Value $Global:gblTo}
      if($Global:gblDelimiter)          {Set-Registry -RegistryKey $RegistryKey -ValueName "Delimiter"                      -Value $Global:gblDelimiter}
      if($Global:gblCopyFiles)          {Set-Registry -Boolean -RegistryKey $RegistryKey -ValueName "CopyFiles"             -Value $Global:gblCopyFiles}
      if($Global:gblSummary)            {Set-Registry -Boolean -RegistryKey $RegistryKey -ValueName "Summary"               -Value $Global:gblSummary}
      if($Global:gblLookFor)            {Set-Registry -Boolean -RegistryKey $RegistryKey -ValueName "LookFor"               -Value $Global:gblLookFor}
      if($Global:gblExactMatchLocation) {Set-Registry -Boolean -RegistryKey $RegistryKey -ValueName "ExactMatchLocation"    -Value $Global:gblExactMatchLocation}
      if($Global:gblExactMatchContainer){Set-Registry -Boolean -RegistryKey $RegistryKey -ValueName "ExactMatchContainer"   -Value $Global:gblExactMatchContainer}
      if($Global:gblIncludeSubFolders)  {Set-Registry -Boolean -RegistryKey $RegistryKey -ValueName "IncludeSubFolders"     -Value $Global:gblIncludeSubFolders}
      if($Global:gblSaveAsHTMLPage)     {Set-Registry -Boolean -RegistryKey $RegistryKey -ValueName "SaveAsHTMLPage"        -Value $Global:gblSaveAsHTMLPage}
     }
   }


# =============================================================================================================================================
# End function block
# =============================================================================================================================================

# =============================================================================================================================================
# Check if the parameter -LookFor has not been forgotten.
# =============================================================================================================================================

  # Clear-Host

  $Message     = ""
  $bolError    = $false
  $RegistryKey = "HKCU:Software\VroomSoft\InventoryIvantiBuildingBlocks"

  # =============================================================================================================================================
  # Check if incorrect combination of parameters is used. If so, correct it or throw an error. 
  # Incorrect combinations are 
  #   - LookFor is used, but no InTitle, InCommand parameters, InParameter, InGroupOrUser Locations and Containers parameters
  #   - CopyFiles is used, but no InTitle, InCommand parameters, InParameter, InGroupOrUser Locations and Containers parameters
  #   - CopyFiles is used, but no To parameter
  #   - InTitle, InCommand parameters, InParameter, InGroupOrUser Locations or Containers parameters are used, but no LookFor parameter
  # =============================================================================================================================================

  if($LookFor -and (-not $InAppID -and -not $InTitle -and -not $InCommandLine -and -not $InParameter -and -not $InFileTypes -and -not $InGroupOrUser -and -not $InLocations -and -not $InContainers))
   {
    $bolError = $true
    $Message = "[Error] LookFor is used, but not InAppID, InTitle, InCommand, InParameter, File Types, Group or User, Locations or Containers. Please specify either the InTitle, InCommand, InParameter, InGroupOrUser, InLocations or InContainers parameter."
   }

  if(-not($LookFor) -and ($InAppID -or $InTitle -or $InCommandLine -or $InParameter -or $InFileTypes -or $InGroupOrUser -or $InLocations -or $InContainers))
   {
    $Message  = "[Warning] LookFor has been added."
    $LookFor  = $True
   }

  if($CopyFiles -and (-not $InAppID -and -not $InTitle -and -not $InCommandLine -and -not $InParameter -and -not $InFileTypes -and -not $InGroupOrUser -and -not $InLocations -and -not $InContainers))
   {
    $bolError = $true
    $Text     = "[Error] CopyFiles is used, but not InAppID, InTitle, InCommand, InParameter, File Types, Group or User, Locations or Containers. Please specify either the InTitle, InCommand, InParameter, InGroupOrUser InLocations or InContainers parameter."
    if(-not($Message))
     {
      $Message = $Text
     }
      else
     {
      $Message += "`n$text"
     }
    }

  if(-not($To) -and $CopyFiles)
   {
    $bolError = $true
    $Text     = "[Error] CopyFiles is used, but To has not been specified. Please specify the To location."
    if(-not($Message))
     {
      $Message = $Text
     }
      else
     {
      $Message += "`n$text"
     }
    }

# =============================================================================================================================================
# Define the variables
# =============================================================================================================================================

  if($ClearUserSettings -and (Test-Path $RegistryKey))
   {
    Remove-Item -Path $RegistryKey -Force | Out-Null
   }

  if( -not($Silent))
   { 
    if(-not($NoUserSettings))
     {  

      Add-EntryToLogFile -Entry "Reading the user settings from the registry: $RegistryKey."
 
      if(-not($Global:gblDirectory))
       {
        $tmpValue1 = Read-Registry -RegistryKey $RegistryKey -ValueName "Directory"
        if($tmpValue1) {$Global:gblDirectory                       = $tmpValue1} else {$Global:gblDirectory           = $Directory}
       }

      if(-not($Global:gblOutputDirectory))
       {
        $tmpValue1 = Read-Registry -RegistryKey $RegistryKey -ValueName "OutputDirectory"
        if($tmpValue1) {$Global:gblOutputDirectory                 = $tmpValue1} else {$Global:gblOutputDirectory     = $OutputDirectory}
       }
      
      if(-not($Global:gblLogPath))
       {
        $tmpValue1 = Read-Registry -RegistryKey $RegistryKey -ValueName "LogPath"
        if($tmpValue1) {$Global:gblLogPath                         = $tmpValue1} else {$Global:gblLogPath             = $LogPath}
       }

      if(-not($Global:gblInAppID))
       {
        $tmpValue1 = Read-Registry -RegistryKey $RegistryKey -ValueName "InAppID"
        if($tmpValue1) {$Global:gblInAppID                         = $tmpValue1} else {$Global:gblInAppID             = $InAppID}
       }

      if(-not($Global:gblInTitle))
       {
        $tmpValue1 = Read-Registry -RegistryKey $RegistryKey -ValueName "InTitle"
        if($tmpValue1) {$Global:gblInTitle                         = $tmpValue1} else {$Global:gblInTitle             = $InTitle}
       }

      if(-not($Global:gblInCommandLine))
       {
        $tmpValue1 = Read-Registry -RegistryKey $RegistryKey -ValueName "InCommandLine"
        if($tmpValue1) {$Global:gblInCommandLine                   = $tmpValue1} else {$Global:gblInCommandLine       = $InCommandLine}
       }

      if(-not($Global:gblInParameter))
       {
        $tmpValue1 = Read-Registry -RegistryKey $RegistryKey -ValueName "InParameter"
        if($tmpValue1) {$Global:gblInParameter                     = $tmpValue1} else {$Global:gblInParameter         = $InParameter}
       }

      if(-not($Global:gblInFileTypes))
       {
        $tmpValue1 = Read-Registry -RegistryKey $RegistryKey -ValueName "InFileTypes"
        if($tmpValue1) {$Global:gblInFileTypes                     = $tmpValue1} else {$Global:gblInFileTypes         = $InFileTypes}
       }

      if(-not($Global:gblInGroupOrUser))
       {
        $tmpValue1 = Read-Registry -RegistryKey $RegistryKey -ValueName "InGroupOrUser"
        if($tmpValue1) {$Global:gblInGroupOrUser                   = $tmpValue1} else {$Global:gblInGroupOrUser       = $InGroupOrUser}
       }

      if(-not($Global:gblInLocations))
       {
        $tmpValue1 = Read-Registry -RegistryKey $RegistryKey -ValueName "InLocations"
        if($tmpValue1) {$Global:gblInLocations                     = $tmpValue1} else {$Global:gblInLocations         = $InLocations}
       }

      if(-not($Global:gblInContainers))
       {
        $tmpValue1 = Read-Registry -RegistryKey $RegistryKey -ValueName "InContainers"
        if($tmpValue1) {$Global:gblInContainers                    = $tmpValue1} else {$Global:gblInContainers        = $InContainers}
       }

      if(-not($Global:gblTo))
       {
        $tmpValue1 = Read-Registry -RegistryKey $RegistryKey -ValueName "To"
        if($tmpValue1) {$Global:gblTo                              = $tmpValue1} else {$Global:gblTo                  = $To}
       }

      if(-not($Global:gblDelimiter))
       {
        $tmpValue1 = Read-Registry -RegistryKey $RegistryKey -ValueName "Delimiter"
        if($tmpValue1) {$Global:gblDelimiter                       = $tmpValue1} else {$Global:gblDelimiter           = $Delimiter}
       }

      if(-not($Global:gblCopyFiles))
       {
        $tmpValue1 = Read-Registry -RegistryKey $RegistryKey -ValueName "CopyFiles"
        if($tmpValue1) {[bool]$Global:gblCopyFiles                 = $tmpValue1} else {$Global:gblCopyFiles           = $CopyFiles}
       }
      
      if(-not($Global:gblDetailedLogging))
       {
        $tmpValue1 = Read-Registry -RegistryKey $RegistryKey -ValueName "DetailedLogging"
        if($tmpValue1) {[bool]$Global:gblDetailedLogging           = $tmpValue1} else {$Global:gblDetailedLogging     = $DetailedLogging}
       }

      if(-not($Global:gblSummary))
       {
        $tmpValue1 = Read-Registry -RegistryKey $RegistryKey -ValueName "Summary"
        if($tmpValue1) {[bool]$Global:gblSummary                   = $tmpValue1} else {$Global:gblSummary             = $Summary}
       }

      if(-not($Global:gblLookFor))
       {
        $tmpValue1 = Read-Registry -RegistryKey $RegistryKey -ValueName "LookFor"
        if($tmpValue1) {$Global:gblLookFor                         = $tmpValue1} else {$Global:gblLookFor             = $LookFor}
       }

      if(-not($Global:gblExactMatchLocation))
       {
        $tmpValue1 = Read-Registry -RegistryKey $RegistryKey -ValueName "ExactMatchLocation"
        if($tmpValue1) {[bool]$Global:gblExactMatchLocation        = $tmpValue1} else {$Global:gblExactMatchLocation  = $ExactMatchLocation}
       }

      if(-not($Global:gblExactMatchContainer))
       {
        $tmpValue1 = Read-Registry -RegistryKey $RegistryKey -ValueName "ExactMatchContainer"
        if($tmpValue1) {[bool]$Global:gblExactMatchContainer       = $tmpValue1} else {$Global:gblExactMatchContainer = $ExactMatchContainer}
       }

      if(-not($Global:gblIncludeSubFolders))
       {
        $tmpValue1 = Read-Registry -RegistryKey $RegistryKey -ValueName "IncludeSubFolders"
        if($tmpValue1) {[bool]$Global:gblIncludeSubFolders         = $tmpValue1} else {$Global:gblIncludeSubFolders   = $IncludeSubFolders}
       }

      if(-not($Global:gblSaveAsHTMLPage))
       {
        $tmpValue1 = Read-Registry -RegistryKey $RegistryKey -ValueName "SaveAsHTMLPage"
        if($tmpValue1) {[bool]$Global:gblSaveAsHTMLPage            = $tmpValue1} else {$Global:gblSaveAsHTMLPage      = $SaveAsHTMLPage}
       }
     }
   }
  
  $Global:gblLogFile             = ""  
  $Global:gblSilent              = $Silent
  $Global:gblNoProgressBar       = $NoProgressBar
  $Global:gblarrTable            = @()
  $Results                    = @()
  $valCounter                 = 1
  $bolMaxComputers            = $False
   
  if(-not($Global:gblOutputDirectory))
   {
    $Global:gblOutputDirectory   = Split-Path -parent $MyInvocation.MyCommand.Definition
   }

  if(-not $Global:gblDirectory)
   {
    $Global:gblDirectory   = Split-Path -parent $MyInvocation.MyCommand.Definition
   }

  if(-not(test-path $Global:gblOutputDirectory))
   {
    $Returntext, $bolResult = Create-Folder -FolderName $Global:gblOutputDirectory
    if($bolResult)
     {
      if(-not($Message))
       {
        $Message = $Returntext
       }
        else
       {
        $Message = "`n$Returntext"
       }
     }
      else
     {
      Write-Error $Returntext -Category WriteError
      Exit 2
     }
   }

  if(-not($Global:gblLogPath))
   {
    $Global:gblLogPath   = Split-Path -parent $MyInvocation.MyCommand.Definition
   }

  if(-not(test-path $Global:gblLogPath))
   {
    $Returntext, $bolResult = Create-Folder -FolderName $Global:gblLogPath
    if($bolResult)
     {
      if(-not($Message))
       {
        $Message = $Returntext
       }
        else
       {
        $Message = "`n$Returntext"
       }
     }
      else
     {
      Write-Error $Returntext -Category WriteError
      Exit 2
     }
   }

# =============================================================================================================================================
# Define the results file. This file contains all the results.
# =============================================================================================================================================
 
  $strLastPartOfFileName = " ($((Get-Date).ToString('G')))"
  $strLastPartOfFileName = $strLastPartOfFileName -replace ":","-"
  $strLastPartOfFileName = $strLastPartOfFileName -replace "/","-"
  $PreFixLogFile         = "ExportIvantiBuildingBlock"
   
  if($Global:gblDetailedLogging)
   {
    $Global:gblLogFile = $Global:gblLogPath + "\"+ $PreFixLogFile + $($strLastPartOfFileName + ".log")
    New-Item $Global:gblLogFile -ItemType File -Force | Out-Null
   }

  if($Message)
   {
    if(-not($bolError))
     {
      Add-EntryToLogFile -Entry "[Warning]: $Message"
     }
      else
     {
      Add-EntryToLogFile -Entry "$Message"
      Add-EntryToLogFile -Entry "This script will now quit."
      Write-Error $Message -Category CloseError
      Exit 3
     }
   }

# =============================================================================================================================================
# Find all the arguments and put them in the log file
# Source: https://ss64.com/ps/psboundparameters.html
# =============================================================================================================================================

  $TableWithParameters  = @()
  $RecordWithParameters = [ordered] @{"Key"     = "";
                                      "Value"   = ""}
  
  ForEach($boundparam in $PSBoundParameters.GetEnumerator()) 
   {
    $tmpValue                     = $($boundparam.Value)
    $Value                        = ""
    if($tmpValue -is [array])
     {
      ForEach ($object in $tmpValue)
       {
        if(-not($value))
         {
          $Value = $object
         }
          else
         {
          $Value +=",$($object)"
         }
       }
     }
      else
     {
      $Value = $tmpValue
     }
    $RecordWithParameters."Key"   = $($boundparam.Key)
    $RecordWithParameters."Value" = $Value
    $objRecordWithParameters      = New-Object PSObject -Property $RecordWithParameters
    $TableWithParameters         += $objRecordWithParameters

    Add-EntryToLogFile -Entry "Key: $($boundparam.Key) Value: $Value" 
   }
   
# =============================================================================================================================================
# Create the folder where all the files have to be copied to. Only if the To parameter is used.
# =============================================================================================================================================

  if($Global:gblTo)
   {
    $Returntext, $bolResult = Create-Folder -FolderName $Global:gblTo
    if($bolResult)
     {
      Add-EntryToLogFile -Entry "The folder $($Global:gblTo) has been created successfully."
     }
      else
     {
      $Text = "There was an error while creating the folder $($Global:gblTo). The script will stop now."
      Add-EntryToLogFile -Entry $Text
      Write-Error $Text -Category WriteError
      Exit 4
     }
   }

# =============================================================================================================================================
# Add assemblies.
# =============================================================================================================================================

  Add-Type -AssemblyName System.Web
  Add-Type -AssemblyName System.Windows.Forms
  
# =============================================================================================================================================
# Forms block
# =============================================================================================================================================

  if(-not($Silent))
  {

  $frmApplBuildingBlocks        = New-Object 'System.Windows.Forms.Form'
  $ProgressBar                  = New-Object 'System.Windows.Forms.ProgressBar'
  $chkDetailedLogging           = New-Object 'System.Windows.Forms.CheckBox'
  $chkSubDirsIBB                = New-Object 'System.Windows.Forms.CheckBox'
  $chkSummary                   = New-Object 'System.Windows.Forms.CheckBox'
  $chkSaveAsHTMLPage            = New-Object 'System.Windows.Forms.CheckBox'
  $chkCopyFilesTo               = New-Object 'System.Windows.Forms.CheckBox'
  $chkExactMatchContainer       = New-Object 'System.Windows.Forms.CheckBox'
  $grpOtherSettings             = New-Object 'System.Windows.Forms.GroupBox'
  $grpVariousSettings           = New-Object 'System.Windows.Forms.GroupBox'
  $grpSearchFor                 = New-Object 'System.Windows.Forms.GroupBox'
  $chkExactMatchLocation        = New-Object 'System.Windows.Forms.CheckBox'
  $lblWorkSpaces                = New-Object 'System.Windows.Forms.Label'
  $lblLocations                 = New-Object 'System.Windows.Forms.Label'
  $lblGroupsOrUsers             = New-Object 'System.Windows.Forms.Label'
  $lblFileTypes                 = New-Object 'System.Windows.Forms.Label'
  $lblParameters                = New-Object 'System.Windows.Forms.Label'
  $lblCommandLine               = New-Object 'System.Windows.Forms.Label'
  $lblTitle                     = New-Object 'System.Windows.Forms.Label'
  $lblDelimiter                 = New-Object 'System.Windows.Forms.Label'
  $lblSummary                   = New-Object 'System.Windows.Forms.Label'
  $lblSaveAsHTMLPage            = New-Object 'System.Windows.Forms.Label'
  $lblAppID                     = New-Object 'System.Windows.Forms.Label'
  $lblOutputDirectory           = New-Object 'System.Windows.Forms.Label'
  $lblDirectoryWithTheIvan      = New-Object 'System.Windows.Forms.Label'
  $lblCopyFilesTo               = New-Object 'System.Windows.Forms.Label'
  $lblLogDir                    = New-Object 'System.Windows.Forms.Label'
  $txtLocations                 = New-Object 'System.Windows.Forms.TextBox'
  $txtGroupsOrUsers             = New-Object 'System.Windows.Forms.TextBox'
  $txtFileTypes                 = New-Object 'System.Windows.Forms.TextBox'
  $txtParameters                = New-Object 'System.Windows.Forms.TextBox'
  $txtCommandLines              = New-Object 'System.Windows.Forms.TextBox'
  $txtTitles                    = New-Object 'System.Windows.Forms.TextBox'
  $txtOutputDirectory           = New-Object 'System.Windows.Forms.TextBox'
  $txtDirectoryWithTheIvan      = New-Object 'System.Windows.Forms.TextBox'
  $txtWorkSpaces                = New-Object 'System.Windows.Forms.TextBox'
  $txtDelimiter                 = New-Object 'System.Windows.Forms.TextBox'
  $txtAppIDs                    = New-Object 'System.Windows.Forms.TextBox'
  $txtPercentage                = New-Object 'System.Windows.Forms.TextBox'
  $txtCopyFilesTo               = New-Object 'System.Windows.Forms.TextBox'
  $txtLogDir                    = New-Object 'System.Windows.Forms.TextBox'
  $datagridview1                = New-Object 'System.Windows.Forms.DataGridView'
  $btnRunInventory              = New-Object 'System.Windows.Forms.Button'
  $btnExit                      = New-Object 'System.Windows.Forms.Button'
  $btnBrowseOutputDir           = New-Object 'System.Windows.Forms.Button'
  $btnBrowseABB                 = New-Object 'System.Windows.Forms.Button'
  $btnCopyFilesTo               = New-Object 'System.Windows.Forms.Button'
  $btnCancel                    = New-Object 'System.Windows.Forms.Button'
  $ToolTips                     = New-Object 'System.Windows.Forms.ToolTip'
  #
  # frmApplBuildingBlocks
  #
  $frmApplBuildingBlocks.Controls.Add($txtLogDir)
  $frmApplBuildingBlocks.Controls.Add($lblLogDir)
  $frmApplBuildingBlocks.Controls.Add($btnCopyFilesTo)
  $frmApplBuildingBlocks.Controls.Add($chkCopyFilesTo)
  $frmApplBuildingBlocks.Controls.Add($txtCopyFilesTo)
  $frmApplBuildingBlocks.Controls.Add($lblCopyFilesTo)
  $frmApplBuildingBlocks.Controls.Add($btnCancel)
  $frmApplBuildingBlocks.Controls.Add($Progressbar)
  $frmApplBuildingBlocks.Controls.Add($txtPercentage)
  $frmApplBuildingBlocks.Controls.Add($pnlProgressbar)
  $frmApplBuildingBlocks.Controls.Add($chkDetailedLogging)
  $frmApplBuildingBlocks.Controls.Add($chkSubDirsIBB)
  $frmApplBuildingBlocks.Controls.Add($grpOtherSettings)
  $frmApplBuildingBlocks.Controls.Add($datagridview1)
  $frmApplBuildingBlocks.Controls.Add($btnRunInventory)
  $frmApplBuildingBlocks.Controls.Add($btnExit)
  $frmApplBuildingBlocks.Controls.Add($btnBrowseOutputDir)
  $frmApplBuildingBlocks.Controls.Add($txtOutputDirectory)
  $frmApplBuildingBlocks.Controls.Add($lblOutputDirectory)
  $frmApplBuildingBlocks.Controls.Add($btnBrowseABB)
  $frmApplBuildingBlocks.Controls.Add($lblDirectoryWithTheIvan)
  $frmApplBuildingBlocks.Controls.Add($txtDirectoryWithTheIvan)
  $frmApplBuildingBlocks.AutoScaleDimensions             = New-Object System.Drawing.SizeF(6, 13)
  $frmApplBuildingBlocks.AutoScaleMode                   = 'Font'
  $frmApplBuildingBlocks.ClientSize                      = New-Object System.Drawing.Size(1337, 794)
  $frmApplBuildingBlocks.FormBorderStyle                 = 'Fixed3D'
  $frmApplBuildingBlocks.Name                            = 'frmApplBuildingBlocks'
  $frmApplBuildingBlocks.StartPosition                   = 'CenterScreen'
  $frmApplBuildingBlocks.Text                            = 'Inventory Ivanti Application Building Blocks v0.3'
  #
  # txtLogDir
  #
  $txtLogDir.Location                                    = New-Object System.Drawing.Point(348, 113)
  $txtLogDir.Name                                        = 'txtLogDir'
  $txtLogDir.Size                                        = New-Object System.Drawing.Size(668, 20)
  $txtLogDir.ReadOnly                                    = $True
  #
  # lblLogDir
  #
  $lblLogDir.AutoSize                                    = $True
  $lblLogDir.Font                                        = [System.Drawing.Font]::new('Microsoft Sans Serif', '9.75')
  $lblLogDir.Location                                    = New-Object System.Drawing.Point(12, 114)
  $lblLogDir.Name                                        = 'lblLogDir'
  $lblLogDir.Size                                        = New-Object System.Drawing.Size(88, 16)
  $lblLogDir.Text                                        = 'Log directory:'
  #
  # btnCopyFilesTo
  #
  $btnCopyFilesTo.Location                               = New-Object System.Drawing.Point(1250, 141)
  $btnCopyFilesTo.Name                                   = 'btnCopyFilesTo'
  $btnCopyFilesTo.Size                                   = New-Object System.Drawing.Size(75, 25)
  $btnCopyFilesTo.TabIndex                               = 20
  $btnCopyFilesTo.Text                                   = 'Browse'
  $btnCopyFilesTo.UseVisualStyleBackColor                = $True
  #
  # chkCopyFilesTo
  #
  $chkCopyFilesTo.Location                               = New-Object System.Drawing.Point(1032, 144)
  $chkCopyFilesTo.Name                                   = 'chkCopyFilesTo'
  $chkCopyFilesTo.Size                                   = New-Object System.Drawing.Size(141, 24)
  $chkCopyFilesTo.TabIndex                               = 19
  $chkCopyFilesTo.Text                                   = 'Copy XML Files'
  $chkCopyFilesTo.UseVisualStyleBackColor = $True
  $ToolTips.SetToolTip($chkCopyFilesTo, 'Select if you want to copy files that match the criterea to the given folder.')
  #
  # txtCopyFilesTo
  #
  $txtCopyFilesTo.Location                               = New-Object System.Drawing.Point(348, 146)
  $txtCopyFilesTo.Name                                   = 'txtCopyFilesTo'
  $txtCopyFilesTo.Size                                   = New-Object System.Drawing.Size(668, 20)
  $txtCopyFilesTo.TabIndex                               = 18
  #
  # lblCopyFilesTo
  #
  $lblCopyFilesTo.AutoSize                               = $True
  $lblCopyFilesTo.Font                                   = [System.Drawing.Font]::new('Microsoft Sans Serif', '9.75')
  $lblCopyFilesTo.Location                               = New-Object System.Drawing.Point(12, 148)
  $lblCopyFilesTo.Name                                   = 'lblCopyFilesTo'
  $lblCopyFilesTo.Size                                   = New-Object System.Drawing.Size(188, 16)
  $lblCopyFilesTo.TabIndex                               = 17
  $lblCopyFilesTo.Text                                   = 'Copy the XML files to directory:'
  #
  # btnCancel
  #
  $btnCancel.Location                                    = New-Object System.Drawing.Point(1254, 732)
  $btnCancel.Name                                        = 'btnCancel'
  $btnCancel.Size                                        = New-Object System.Drawing.Size(75, 50)
  $btnCancel.TabIndex                                    = 16
  $btnCancel.Text                                        = 'Cancel'
  $btnCancel.UseVisualStyleBackColor                     = $True
  $ToolTips.SetToolTip($btnCancel, 'Exit the application.')
  $btnCancel.add_Click({$frmApplBuildingBlocks.Close()})
  #
  # txtPercentage
  #
  $txtPercentage.Location                                = New-Object System.Drawing.Point(442, 452)
  $txtPercentage.Name                                    = 'txtPercentage'
  $txtPercentage.Size                                    = New-Object System.Drawing.Size(60, 20)
  $txtPercentage.TextAlign                               = 'Center'
  $txtPercentage.Visible                                 = $False
  #
  # ProgressBar
  #
  $ProgressBar.Location                                  = New-Object System.Drawing.Point(277, 435)
  $ProgressBar.Name                                      = 'ProgressBar'
  $ProgressBar.Size                                      = New-Object System.Drawing.Size(400, 50)
  $ProgressBar.Step                                      = 1
  $ProgressBar.Style                                     = 'Blocks'
  $ProgressBar.Visible                                   = $false
  #
  # chkDetailedLogging
  #
  $chkDetailedLogging.Location                           = New-Object System.Drawing.Point(1032, 113)
  $chkDetailedLogging.Name                               = 'chkDetailedLogging'
  $chkDetailedLogging.Size                               = New-Object System.Drawing.Size(141, 24)
  $chkDetailedLogging.TabIndex                           = 13
  $chkDetailedLogging.Text                               = 'Create logfile'
  $chkDetailedLogging.UseVisualStyleBackColor            = $True
  $chkDetailedLogging.Enabled                            = $False
  $ToolTips.SetToolTip($chkDetailedLogging, 'Select if you want to create a log file. This option can only be set from the command line.')
  #
  # chkSubDirsIBB
  #
  $chkSubDirsIBB.Location                                = New-Object System.Drawing.Point(1032, 40)
  $chkSubDirsIBB.Name                                    = 'chkSubDirsIBB'
  $chkSubDirsIBB.Size                                    = New-Object System.Drawing.Size(141, 24)
  $chkSubDirsIBB.TabIndex                                = 12
  $chkSubDirsIBB.Text                                    = 'Include subfolders'
  $chkSubDirsIBB.UseVisualStyleBackColor                 = $True
  $ToolTips.SetToolTip($chkSubDirsIBB, 'Select if you want to search in the subfolders to the building block XML files.')
  #
  # grpOtherSettings
  #
  $grpOtherSettings.Controls.Add($grpVariousSettings)
  $grpOtherSettings.Controls.Add($grpSearchFor)
  $grpOtherSettings.Location                             = New-Object System.Drawing.Point(858, 172)
  $grpOtherSettings.Name                                 = 'grpOtherSettings'
  $grpOtherSettings.Size                                 = New-Object System.Drawing.Size(467, 554)
  $grpOtherSettings.TabIndex                             = 11
  $grpOtherSettings.TabStop                              = $False
  $grpOtherSettings.Text                                 = 'Other settings'
  #
  # grpVariousSettings
  #
  $grpVariousSettings.Controls.Add($lblDelimiter)
  $grpVariousSettings.Controls.Add($lblSummary)
  $grpVariousSettings.Controls.Add($lblSaveAsHTMLPage)
  $grpVariousSettings.Controls.Add($txtDelimiter)
  $grpVariousSettings.Controls.Add($chkSummary)
  $grpVariousSettings.Controls.Add($chkSaveAsHTMLPage)
  $grpVariousSettings.Location                           = New-Object System.Drawing.Point(12, 414)
  $grpVariousSettings.Name                               = 'grpVariousSettings'
  $grpVariousSettings.Size                               = New-Object System.Drawing.Size(443, 134)
  $grpVariousSettings.TabIndex                           = 1
  $grpVariousSettings.TabStop                            = $False
  $grpVariousSettings.Text                               = 'Various settings'
  $grpVariousSettings.add_Enter($grpVariousSettings_Enter)
  #
  # lblDelimiter
  #
  $lblDelimiter.AutoSize                                 = $True
  $lblDelimiter.Location                                 = New-Object System.Drawing.Point(7, 106)
  $lblDelimiter.Name                                     = 'lblDelimiter'
  $lblDelimiter.Size                                     = New-Object System.Drawing.Size(51, 13)
  $lblDelimiter.TabIndex                                 = 5
  $lblDelimiter.Text                                     = 'Delimiter'
  #
  # lblSummary
  #
  $lblSummary.AutoSize                                   = $True
  $lblSummary.Location                                   = New-Object System.Drawing.Point(7, 75)
  $lblSummary.Name                                       = 'lblSummary'
  $lblSummary.Size                                       = New-Object System.Drawing.Size(50, 13)
  $lblSummary.TabIndex                                   = 4
  $lblSummary.Text                                       = 'Summary'
  $lblSummary.add_Click($lblSummary_Click)
  #
  # lblSaveAsHTMLPage
  #
  $lblSaveAsHTMLPage.AutoSize                            = $True
  $lblSaveAsHTMLPage.Location                            = New-Object System.Drawing.Point(6, 45)
  $lblSaveAsHTMLPage.Name                                = 'lblSaveAsHTMLPage'
  $lblSaveAsHTMLPage.Size                                = New-Object System.Drawing.Size(107, 13)
  $lblSaveAsHTMLPage.TabIndex                            = 3
  $lblSaveAsHTMLPage.Text                                = 'Save as HTML Page'
  #
  # txtDelimiter
  #
  $txtDelimiter.Location                                 = New-Object System.Drawing.Point(333, 106)
  $txtDelimiter.Name                                     = 'txtDelimiter'
  $txtDelimiter.Size                                     = New-Object System.Drawing.Size(53, 20)
  $txtDelimiter.TabIndex                                 = 2
  $txtDelimiter.add_TextChanged($txtDelimiter_TextChanged)
  #
  # chkSummary
  #
  $chkSummary.Location                                   = New-Object System.Drawing.Point(333, 75)
  $chkSummary.Name                                       = 'chkSummary'
  $chkSummary.Size                                       = New-Object System.Drawing.Size(104, 24)
  $chkSummary.TabIndex                                   = 1
  $chkSummary.UseVisualStyleBackColor                    = $True
  $ToolTips.SetToolTip($chkSummary, 'Select if you only want to view the most important columns in the overview.')
  #
  # chkSaveAsHTMLPage
  #
  $chkSaveAsHTMLPage.Location                            = New-Object System.Drawing.Point(333, 45)
  $chkSaveAsHTMLPage.Name                                = 'chkSaveAsHTMLPage'
  $chkSaveAsHTMLPage.Size                                = New-Object System.Drawing.Size(104, 24)
  $chkSaveAsHTMLPage.TabIndex                            = 0
  $chkSaveAsHTMLPage.UseVisualStyleBackColor             = $True
  $ToolTips.SetToolTip($chkSaveAsHTMLPage, 'Select if you want to save the results as an HTML file. Default is a CSV file.')
  #
  # grpSearchFor
  #
  $grpSearchFor.Controls.Add($lblWorkSpaces)
  $grpSearchFor.Controls.Add($lblLocations)
  $grpSearchFor.Controls.Add($txtWorkSpaces)
  $grpSearchFor.Controls.Add($lblGroupsOrUsers)
  $grpSearchFor.Controls.Add($lblFileTypes)
  $grpSearchFor.Controls.Add($lblParameters)
  $grpSearchFor.Controls.Add($lblCommandLine)
  $grpSearchFor.Controls.Add($lblTitle)
  $grpSearchFor.Controls.Add($txtLocations)
  $grpSearchFor.Controls.Add($txtGroupsOrUsers)
  $grpSearchFor.Controls.Add($txtFileTypes)
  $grpSearchFor.Controls.Add($txtParameters)
  $grpSearchFor.Controls.Add($txtCommandLines)
  $grpSearchFor.Controls.Add($txtTitles)
  $grpSearchFor.Controls.Add($lblAppID)
  $grpSearchFor.Controls.Add($txtAppIDs)
  $grpSearchFor.Controls.Add($chkExactMatchContainer)
  $grpSearchFor.Controls.Add($chkExactMatchLocation)

  $grpSearchFor.Location                                 = New-Object System.Drawing.Point(12, 24)
  $grpSearchFor.Name                                     = 'grpSearchFor'
  $grpSearchFor.Size                                     = New-Object System.Drawing.Size(444, 390)
  $grpSearchFor.TabIndex                                 = 0
  $grpSearchFor.TabStop                                  = $False
  $grpSearchFor.Text                                     = 'Search for'
  #
  # lblWorkSpaces
  #
  $lblWorkSpaces.AutoSize                                = $True
  $lblWorkSpaces.Location                                = New-Object System.Drawing.Point(6, 344)
  $lblWorkSpaces.Name                                    = 'lblWorkSpaces'
  $lblWorkSpaces.Size                                    = New-Object System.Drawing.Size(70, 13)
  $lblWorkSpaces.TabIndex                                = 15
  $lblWorkSpaces.Text                                    = 'Workspaces:'
  #
  # lblLocations
  #
  $lblLocations.AutoSize                                 = $True
  $lblLocations.Location                                 = New-Object System.Drawing.Point(6, 298)
  $lblLocations.Name                                     = 'lblLocations'
  $lblLocations.Size                                     = New-Object System.Drawing.Size(56, 13)
  $lblLocations.TabIndex                                 = 14
  $lblLocations.Text                                     = 'Locations:'
  #
  # chkExactMatchLocation
  #
  $chkExactMatchLocation.Location                        = New-Object System.Drawing.Point(9, 311)
  $chkExactMatchLocation.Name                            = 'chkExactMatchLocation'
  $chkExactMatchLocation.Size                            = New-Object System.Drawing.Size(104, 24)
  $chkExactMatchLocation.Text                            = 'Exact match'
  $chkExactMatchLocation.UseVisualStyleBackColor         = $True
  $ToolTips.SetToolTip($chkExactMatchLocation, 'Select if you want to have an exact match on the location.')
  #
  # txtWorkSpaces
  #
  $txtWorkSpaces.Location                                = New-Object System.Drawing.Point(132, 341)
  $txtWorkSpaces.Multiline                               = $True
  $txtWorkSpaces.Name                                    = 'txtWorkSpaces'
  $txtWorkSpaces.Size                                    = New-Object System.Drawing.Size(311, 40)
  $txtWorkSpaces.TabIndex                                = 8
  $txtWorkSpaces.ScrollBars                              = 'Vertical'
  $ToolTips.SetToolTip($txtWorkSpaces, 'Enter the workspaces (zone). Each workspace (zone) on a new line or split with a comma.')
  #
  # chkExactMatchContainer
  #
  $chkExactMatchContainer.Location                       = New-Object System.Drawing.Point(9, 357)
  $chkExactMatchContainer.Name                           = 'chkExactMatchContainer'
  $chkExactMatchContainer.Size                           = New-Object System.Drawing.Size(104, 24)
  $chkExactMatchContainer.Text                           = 'Exact match'
  $chkExactMatchContainer.UseVisualStyleBackColor        = $True
  $ToolTips.SetToolTip($chkExactMatchContainer, 'Select if you want to have an exact match on the container.')
  #
  # lblGroupsOrUsers
  #
  $lblGroupsOrUsers.AutoSize                             = $True
  $lblGroupsOrUsers.Location                             = New-Object System.Drawing.Point(7, 252)
  $lblGroupsOrUsers.Name                                 = 'lblGroupsOrUsers'
  $lblGroupsOrUsers.Size                                 = New-Object System.Drawing.Size(86, 13)
  $lblGroupsOrUsers.TabIndex                             = 13
  $lblGroupsOrUsers.Text                                 = 'Groups or Users:'
  #
  # lblFileTypes
  #
  $lblFileTypes.AutoSize                                 = $True
  $lblFileTypes.Location                                 = New-Object System.Drawing.Point(6, 206)
  $lblFileTypes.Name                                     = 'lblFileTypes'
  $lblFileTypes.Size                                     = New-Object System.Drawing.Size(51, 13)
  $lblFileTypes.TabIndex                                 = 12
  $lblFileTypes.Text                                     = 'Filetypes:'
  #
  # lblParameters
  #
  $lblParameters.AutoSize                                = $True
  $lblParameters.Location                                = New-Object System.Drawing.Point(6, 160)
  $lblParameters.Name                                    = 'lblParameters'
  $lblParameters.Size                                    = New-Object System.Drawing.Size(63, 13)
  $lblParameters.TabIndex                                = 11
  $lblParameters.Text                                    = 'Parameters:'
  #
  # lblCommandLine
  #
  $lblCommandLine.AutoSize                               = $True
  $lblCommandLine.Location                               = New-Object System.Drawing.Point(6, 114)
  $lblCommandLine.Name                                   = 'lblCommandLine'
  $lblCommandLine.Size                                   = New-Object System.Drawing.Size(80, 13)
  $lblCommandLine.TabIndex                               = 10
  $lblCommandLine.Text                                   = 'Command Line:'
  #
  # lblTitle
  #
  $lblTitle.AutoSize                                     = $True
  $lblTitle.Location                                     = New-Object System.Drawing.Point(6, 68)
  $lblTitle.Name                                         = 'lblTitle'
  $lblTitle.Size                                         = New-Object System.Drawing.Size(30, 13)
  $lblTitle.TabIndex                                     = 9
  $lblTitle.Text                                         = 'Title:'
  $lblTitle.add_Click($lblTitle_Click)
  #
  # txtLocations
  #
  $txtLocations.Location                                 = New-Object System.Drawing.Point(132, 295)
  $txtLocations.Multiline                                = $True
  $txtLocations.Name                                     = 'txtLocations'
  $txtLocations.Size                                     = New-Object System.Drawing.Size(311, 40)
  $txtLocations.TabIndex                                 = 7
  $txtLocations.ScrollBars                               = 'Vertical'
  $ToolTips.SetToolTip($txtLocations, 'Enter the locations. Each location on a new line or split with a comma.')
  #
  # txtGroupsOrUsers
  #
  $txtGroupsOrUsers.Location                             = New-Object System.Drawing.Point(132, 249)
  $txtGroupsOrUsers.Multiline                            = $True
  $txtGroupsOrUsers.Name                                 = 'txtGroupsOrUsers'
  $txtGroupsOrUsers.Size                                 = New-Object System.Drawing.Size(311, 40)
  $txtGroupsOrUsers.TabIndex                             = 6
  $txtGroupsOrUsers.ScrollBars                           = 'Vertical'
  $ToolTips.SetToolTip($txtGroupsOrUsers, 'Enter the group or username. Each group or username on a new line or split with a comma.')
  #
  # txtFileTypes
  #
  $txtFileTypes.Location                                 = New-Object System.Drawing.Point(132, 203)
  $txtFileTypes.Multiline                                = $True
  $txtFileTypes.Name                                     = 'txtFileTypes'
  $txtFileTypes.Size                                     = New-Object System.Drawing.Size(311, 40)
  $txtFileTypes.TabIndex                                 = 5
  $txtFileTypes.ScrollBars                               = 'Vertical'
  $ToolTips.SetToolTip($txtFileTypes, 'Enter the filetypes (extensions). Each filetype on a new line or split with a comma.')
  #
  # txtParameters
  #
  $txtParameters.Location                                = New-Object System.Drawing.Point(132, 157)
  $txtParameters.Multiline                               = $True
  $txtParameters.Name                                    = 'txtParameters'
  $txtParameters.Size                                    = New-Object System.Drawing.Size(311, 40)
  $txtParameters.TabIndex                                = 4
  $txtParameters.ScrollBars                              = 'Vertical'
  $ToolTips.SetToolTip($txtParameters, 'Enter the parameters. Each parameter on a new line or split with a comma.')
  #
  # txtCommandLines
  #
  $txtCommandLines.Location                              = New-Object System.Drawing.Point(132, 111)
  $txtCommandLines.Multiline                             = $True
  $txtCommandLines.Name                                  = 'txtCommandLines'
  $txtCommandLines.Size                                  = New-Object System.Drawing.Size(311, 40)
  $txtCommandLines.TabIndex                              = 3
  $txtCommandLines.ScrollBars                            = 'Vertical'
  $ToolTips.SetToolTip($txtCommandLines, 'Enter (a part of) the commandline. Each part on a new line or split with a comma.')
  #
  # txtTitles
  #
  $txtTitles.Location                                    = New-Object System.Drawing.Point(132, 65)
  $txtTitles.Multiline                                   = $True
  $txtTitles.Name                                        = 'txtTitles'
  $txtTitles.Size                                        = New-Object System.Drawing.Size(311, 40)
  $txtTitles.TabIndex                                    = 2
  $txtTitles.ScrollBars                                  = 'Vertical'
  $ToolTips.SetToolTip($txtTitles, 'Enter the title. Each title on a new line or split with a comma.')
  #
  # lblAppID
  #
  $lblAppID.AutoSize                                     = $True
  $lblAppID.Location                                     = New-Object System.Drawing.Point(6, 22)
  $lblAppID.Name                                         = 'lblAppID'
  $lblAppID.Size                                         = New-Object System.Drawing.Size(40, 13)
  $lblAppID.TabIndex                                     = 1
  $lblAppID.Text                                         = 'AppID:'
  #
  # txtAppIDs
  #
  $txtAppIDs.Location                                    = New-Object System.Drawing.Point(132, 19)
  $txtAppIDs.Multiline                                   = $True
  $txtAppIDs.Name                                        = 'txtAppIDs'
  $txtAppIDs.Size                                        = New-Object System.Drawing.Size(311, 40)
  $txtAppIDs.TabIndex                                    = 0
  $txtAppIDs.ScrollBars                                  = 'Vertical'
  $ToolTips.SetToolTip($txtAppIDs, 'Enter the AppID''s. Each AppID on a new line or split with a comma.')
  #
  # datagridview1
  #
  $DataGridViewCellStyle_1                               = New-Object 'System.Windows.Forms.DataGridViewCellStyle'
  $DataGridViewCellStyle_1.Alignment                     = 'TopLeft'
  $DataGridViewCellStyle_1.BackColor                     = [System.Drawing.SystemColors]::Window 
  $DataGridViewCellStyle_1.Font                          = [System.Drawing.Font]::new('Microsoft Sans Serif', '8.25')
  $DataGridViewCellStyle_1.ForeColor                     = [System.Drawing.SystemColors]::ControlText 
  $DataGridViewCellStyle_1.SelectionBackColor            = [System.Drawing.SystemColors]::Highlight 
  $DataGridViewCellStyle_1.SelectionForeColor            = [System.Drawing.SystemColors]::HighlightText 
  $DataGridViewCellStyle_1.WrapMode                      = 'True'
  $datagridview1.DefaultCellStyle                        = $DataGridViewCellStyle_1
  $datagridview1.Location                                = New-Object System.Drawing.Point(12, 172)
  $datagridview1.Name                                    = 'datagridview1'
  $datagridview1.Size                                    = New-Object System.Drawing.Size(838, 610)
  $datagridview1.TabIndex                                = 10
  $datagridview1.ColumnHeadersHeightSizeMode             = 'AutoSize'
  $datagridview1.AutoSizeRowsMode                        = 'AllCells'
  $datagridview1.AutoSizeColumnsMode                     = 'AllCells'
  #
  # btnRunInventory
  #
  $btnRunInventory.Location                              = New-Object System.Drawing.Point(1092, 732)
  $btnRunInventory.Name                                  = 'btnRunInventory'
  $btnRunInventory.Size                                  = New-Object System.Drawing.Size(75, 50)
  $btnRunInventory.TabIndex                              = 9
  $btnRunInventory.Text                                  = 'Run Inventory'
  $btnRunInventory.UseVisualStyleBackColor               = $True
  $ToolTips.SetToolTip($btnRunInventory, 'Search for the building block XML files and fill the grid.')
  #
  # btnExit
  #
  $btnExit.Location                                      = New-Object System.Drawing.Point(1173, 732)
  $btnExit.Name                                          = 'btnExit'
  $btnExit.Size                                          = New-Object System.Drawing.Size(75, 50)
  $btnExit.TabIndex                                      = 8
  $btnExit.Text                                          = 'Save and exit'
  $btnExit.UseVisualStyleBackColor                       = $True
  $ToolTips.SetToolTip($btnExit, 'Save the results as an HTML or CSV file and leave the application.')
  $btnExit.add_Click($btnExit_Click)
  #
  # btnBrowseOutputDir
  #
  $btnBrowseOutputDir.Location                           = New-Object System.Drawing.Point(1250, 80)
  $btnBrowseOutputDir.Name                               = 'btnBrowseOutputDir'
  $btnBrowseOutputDir.Size                               = New-Object System.Drawing.Size(75, 25)
  $btnBrowseOutputDir.TabIndex                           = 7
  $btnBrowseOutputDir.Text                               = 'Browse'
  $btnBrowseOutputDir.UseVisualStyleBackColor            = $True
  $btnBrowseOutputDir.Visible                            = $True
  #
  # txtOutputDirectory
  #
  $txtOutputDirectory.Location                           = New-Object System.Drawing.Point(348, 83)
  $txtOutputDirectory.Name                               = 'txtOutputDirectory'
  $txtOutputDirectory.Size                               = New-Object System.Drawing.Size(668, 20)
  $txtOutputDirectory.TabIndex                           = 6
  #
  # lblOutputDirectory
  #
  $lblOutputDirectory.AutoSize                            = $True
  $lblOutputDirectory.Font                                = [System.Drawing.Font]::new('Microsoft Sans Serif', '9.75')
  $lblOutputDirectory.Location                            = New-Object System.Drawing.Point(12, 83)
  $lblOutputDirectory.Name                                = 'lblOutputDirectory'
  $lblOutputDirectory.Size                                = New-Object System.Drawing.Size(103, 16)
  $lblOutputDirectory.TabIndex                            = 5
  $lblOutputDirectory.Text                                = 'Output directory:'
  #
  # btnBrowseABB
  #
  $btnBrowseABB.Location                                 = New-Object System.Drawing.Point(1250, 38)
  $btnBrowseABB.Name                                     = 'btnBrowseABB'
  $btnBrowseABB.Size                                     = New-Object System.Drawing.Size(75, 25)
  $btnBrowseABB.TabIndex                                 = 4
  $btnBrowseABB.Text                                     = 'Browse'
  $btnBrowseABB.UseVisualStyleBackColor                  = $True
  $btnBrowseABB.add_Click($btnBrowseABB_Click)
  #
  # lblDirectoryWithTheIvan
  #
  $lblDirectoryWithTheIvan.AutoSize                      = $True
  $lblDirectoryWithTheIvan.Font                          = [System.Drawing.Font]::new('Microsoft Sans Serif', '9.75')
  $lblDirectoryWithTheIvan.Location                      = New-Object System.Drawing.Point(12, 43)
  $lblDirectoryWithTheIvan.Name                          = 'lblDirectoryWithTheIvan'
  $lblDirectoryWithTheIvan.Size                          = New-Object System.Drawing.Size(309, 16)
  $lblDirectoryWithTheIvan.TabIndex                      = 3
  $lblDirectoryWithTheIvan.Text                          = 'Directory with the Ivanti Application Building Blocks:'
  #
  # txtDirectoryWithTheIvan
  #
  $txtDirectoryWithTheIvan.Location                      = New-Object System.Drawing.Point(348, 43)
  $txtDirectoryWithTheIvan.Name                          = 'txtDirectoryWithTheIvan'
  $txtDirectoryWithTheIvan.Size                          = New-Object System.Drawing.Size(668, 20)
  $txtDirectoryWithTheIvan.TabIndex                      = 0
  #
  # ToolTips
  #
  $ToolTips.AutomaticDelay                               = 500
  $ToolTips.AutoPopDelay                                 = 5010
  $ToolTips.InitialDelay                                 = 500
  $ToolTips.IsBalloon                                    = $True
  $ToolTips.ReshowDelay                                  = 100
  $ToolTips.Tag                                          = 'Information'
  $ToolTips.ToolTipIcon                                  = 'Info'
  $ToolTips.ToolTipTitle                                 = 'Additonal information'

  $txtDirectoryWithTheIvan.Text                          = $Global:gblDirectory
  $txtOutputDirectory.Text                               = $Global:gblOutputDirectory
  $txtLogDir.Text                                        = $Global:gblLogPath
  $txtDelimiter.Text                                     = $Global:gblDelimiter
  $txtWorkSpaces.Text                                    = Convert-ArrayToTextForTextBox -ArrayToConvert $Global:gblInContainers
  $txtLocations.Text                                     = Convert-ArrayToTextForTextBox -ArrayToConvert $Global:gblInLocations
  $txtGroupsOrUsers.Text                                 = Convert-ArrayToTextForTextBox -ArrayToConvert $Global:gblInGroupOrUser
  $txtFileTypes.Text                                     = Convert-ArrayToTextForTextBox -ArrayToConvert $Global:gblInFileTypes
  $txtParameters.Text                                    = Convert-ArrayToTextForTextBox -ArrayToConvert $Global:gblInParameter
  $txtCommandLines.Text                                  = Convert-ArrayToTextForTextBox -ArrayToConvert $Global:gblInCommandLine
  $txtTitles.Text                                        = Convert-ArrayToTextForTextBox -ArrayToConvert $Global:gblInTitle
  $txtAppIDs.Text                                        = Convert-ArrayToTextForTextBox -ArrayToConvert $Global:gblInAppID
  $txtCopyFilesTo.Text                                   = $Global:gblTo
  $chkSummary.Checked                                    = $Global:gblSummary
  $chkSaveAsHTMLPage.Checked                             = $Global:gblSaveAsHTMLPage
  $chkSubDirsIBB.Checked                                 = $Global:gblIncludeSubFolders
  $chkDetailedLogging.Checked                            = $Global:gblDetailedLogging
  $chkCopyFilesTo.Checked                                = $Global:gblCopyFiles
  $chkExactMatchLocation.Checked                         = $Global:gblExactMatchLocation
  $chkExactMatchContainer.Checked                        = $Global:gblExactMatchContainer
    
  $btnBrowseOutputDir.add_Click({
       $txtOutputDirectory.Text       = Get-FolderFromButton -InitialDirectory $($txtOutputDirectory.Text)      -Description "Specify the directory where the CSV or HTML file should be saved." -AllowNewFolder
                        })

  $btnBrowseABB.add_Click({
        $txtDirectoryWithTheIvan.Text = Get-FolderFromButton -InitialDirectory $($txtDirectoryWithTheIvan.Text) -Description "Specify the output directory where the building blocks are stored."
                        })

  $btnCopyFilesTo.add_Click({
        $txtCopyFilesTo.Text          = Get-FolderFromButton -InitialDirectory $($txtCopyFilesTo.Text)          -Description "Specify the directory where the building blocks that matches the search criterea should be copied to." -AllowNewFolder
                        })

# =============================================================================================================================================
# End forms block
# =============================================================================================================================================
}
   else
  {
   Process-AllTheBuildingBlocks -DirectoryWithTheXMLFiles $Global:gblDirectory -IncludeTheSubFolders:$Global:gblIncludeSubFolders -GUI:$False
   $CSVOrHTMLFileWithResults   = $Global:gblOutputDirectory + "\"+ $PreFixLogFile + $strLastPartOfFileName
   if($Global:gblSaveAsHTMLPage)
    {
     File -HTMLFileToWrite $($CSVOrHTMLFileWithResults + ".html")
    }
     else
    {
     Write-CSVFile -CSVOrHTMLFileWithResults $($CSVOrHTMLFileWithResults + ".csv")
    }
   
   if($Global:gblDetailedLogging)
    {
     Write-Host "The logfile $($Global:gblLogFile) has been created."
    }
   
   Exit 0
  }

 $btnRunInventory.add_Click({
  $Global:gblarrTable               = @()
  $Global:gblDirectory              = $txtDirectoryWithTheIvan.Text
  $Global:gblLogPath                = $txtLogDir.Text
  $Global:gblInContainers           = Convert-TextFromTextBoxToArray -Text $txtWorkSpaces.Text
  $Global:gblInLocations            = Convert-TextFromTextBoxToArray -Text $txtLocations.Text
  $Global:gblInGroupOrUser          = Convert-TextFromTextBoxToArray -Text $txtGroupsOrUsers.Text
  $Global:gblInFileTypes            = Convert-TextFromTextBoxToArray -Text $txtFileTypes.Text
  $Global:gblInParameter            = Convert-TextFromTextBoxToArray -Text $txtParameters.Text
  $Global:gblInCommandLine          = Convert-TextFromTextBoxToArray -Text $txtCommandLines.Text
  $Global:gblInTitle                = Convert-TextFromTextBoxToArray -Text $txtTitles.Text
  $Global:gblInAppID                = Convert-TextFromTextBoxToArray -Text $txtAppIDs.Text
  $Global:gblIncludeSubFolders      = $chkSubDirsIBB.Checked
  $Global:gblDetailedLogging        = $chkDetailedLogging.Checked
  $Global:gblTo                     = $txtCopyFilesTo.Text
  $Global:gblCopyFiles              = $chkCopyFilesTo.Checked
  $Global:gblExactMatchLocation     = $chkExactMatchLocation.Checked
  $Global:gblExactMatchContainer    = $chkExactMatchContainer.Checked
  
  if($Global:gblTo -and $Global:gblCopyFiles)
   {
    $Returntext, $bolResult = Create-Folder -FolderName $Global:gblTo
    if($bolResult)
     {
      Add-EntryToLogFile -Entry "The folder $($Global:gblTo) has been created successfully."
     }
      else
     {
      $Text = "There was an error while creating the folder $($Global:gblTo). The script will stop now.`r`n"
      $Text += "The script will continue but without copying the files."
      Add-EntryToLogFile -Entry $Text
      $Global:gblCopyFiles = $False
      $Global:gblTo        = ""
     }
   }

  $btnRunInventory.Enabled = $False

  Process-AllTheBuildingBlocks -GUI

  $Global:gblSummary                = $chkSummary.Checked
      If($Global:gblSummary)
       {
        $Global:gblarrTable = $Global:gblarrTable | Select-Object -Property "XML File Name","Start Menu location","Properties - General - ID","Properties - General - Title","Properties - General - Description","Properties - General - Commandline","Properties - General - Parameters","Properties - Settings - Application is enabled","Properties - FileTypes","Access Control - Identy - Type","Access Control - Identy - Selected users and/or groups","Access Control - Location and devices","Access Control - Workspace containers","Remark"
       }
       
   $valCounter = 0
   $datagridview1.DataSource = $null
   $datagridview1.Rows.Clear()
   if($Global:gblarrTable.Count -gt 0)
    {
     $datagridview1.Enabled = $true
     $datagridview1.DataSource = $null
     $datagridview1.DataSource = [System.Collections.ArrayList]$Global:gblarrTable
    }
   $btnRunInventory.Enabled = $True
   $ProgressBar.Visible = $False
   $txtPercentage.Visible = $False
})

 $btnExit.add_Click({

 $Global:gblSummary                = $chkSummary.Checked
 $Global:gblSaveAsHTMLPage         = $chkSaveAsHTMLPage.Checked
 $Global:gblOutputDirectory        = $txtOutputDirectory.Text
 $Global:gblDelimiter              = $txtDelimiter.Text
 $CSVOrHTMLFileWithResults         = $Global:gblOutputDirectory + "\"+ $PreFixLogFile + $strLastPartOfFileName
 
 if(-not($NoUserSettings))
  {
   ReadAndSetSettings -Set -RegistryKey $RegistryKey
  }

 if($chkSaveAsHTMLPage.Checked)
   {
    Write-HTMLFile -HTMLFileToWrite $($CSVOrHTMLFileWithResults + ".html")
   }
    else
   {
    Write-CSVFile -CSVOrHTMLFileWithResults $($CSVOrHTMLFileWithResults + ".csv")
   }
   $frmApplBuildingBlocks.Close()

 if($Global:gblDetailedLogging)
  {
   Write-Host "The logfile $($Global:gblLogFile) has been created."
  }
 })


 [void]$frmApplBuildingBlocks.ShowDialog()
 $frmApplBuildingBlocks.Dispose()

Download the zip file InventoryIvantiApplicationBuildingBlocksWithGUI_v03.zip

Before download...

Continue... ×

Download the zip file InventoryIvantiApplicationBuildingBlocksWithGUI_v02.zip

Before download...

Continue... ×

Download the zip file InventoryIvantiApplicationBuildingBlocksWithGUI_v01.zip

Before download...

Continue... ×