internal/Get-XpoType.ps1

#Requires -Version 5
Set-StrictMode -Version Latest

$script:xpoTypeInfo = @(
    [xpoType]@{AOTpath = @('Classes'); OneLevelAOTPath ='Classes'; UtilType = 45; NodeType = 329; Tag = 'CLS'; FilePrefix = 'Class'; SubTag = ''}
    [xpoType]@{AOTpath = @('Data Dictionary', 'Base Enums'); OneLevelAOTPath ='Base Enums'; UtilType = 40; NodeType = 209; Tag = 'DBE'; FilePrefix = 'Enum'; SubTag = ''}
    [xpoType]@{AOTpath = @('Data Dictionary', 'Extended Data Types'); OneLevelAOTPath ='Extended Data Types'; UtilType = 41; NodeType = 228; Tag = 'UTE'; FilePrefix = 'ExtendedType'; SubTag = ''}
    [xpoType]@{AOTpath = @('Data Dictionary', 'Tables'); OneLevelAOTPath ='Tables'; UtilType = 44; NodeType = 204; Tag = 'DBT'; FilePrefix = 'Table'; SubTag = ''}
    [xpoType]@{AOTpath = @('Data Dictionary', 'Views'); OneLevelAOTPath ='Views'; UtilType = 44; NodeType = 243; Tag = 'VIE'; FilePrefix = 'ViewQuery'; SubTag = ''}
    [xpoType]@{AOTpath = @('Data Dictionary', 'Maps'); OneLevelAOTPath ='Maps'; UtilType = 44; NodeType = 236; Tag = 'MAP'; FilePrefix = 'TableMap'; SubTag = ''}
    [xpoType]@{AOTpath = @('Forms'); OneLevelAOTPath ='Forms'; UtilType = 11; NodeType = 201; Tag = 'FRM'; FilePrefix = 'Form'; SubTag = ''}
    [xpoType]@{AOTpath = @('Jobs'); OneLevelAOTPath ='Jobs'; UtilType = 5; NodeType = 215; Tag = 'JOB'; FilePrefix = 'Job'; SubTag = ''}
    [xpoType]@{AOTpath = @('Menu Items', 'Display'); OneLevelAOTPath ='Display Menu Items'; UtilType = 1; NodeType = 296; Tag = 'FTM'; FilePrefix = 'DisplayTool'; SubTag = '1'}
    [xpoType]@{AOTpath = @('Menu Items', 'Output'); OneLevelAOTPath ='Output Menu Items'; UtilType = 2; NodeType = 296; Tag = 'FTM'; FilePrefix = 'OutputTool'; SubTag = '2'}
    [xpoType]@{AOTpath = @('Menu Items', 'Action'); OneLevelAOTPath ='Action Menu Items'; UtilType = 3; NodeType = 296; Tag = 'FTM'; FilePrefix = 'ActionTool'; SubTag = '3'}
    [xpoType]@{AOTpath = @('Macros'); OneLevelAOTPath ='Macros'; UtilType = 4; NodeType = 218; Tag = 'MCR'; FilePrefix = 'Macro'; SubTag = ''}
    [xpoType]@{AOTpath = @('Menus'); OneLevelAOTPath ='Menus'; UtilType = 16; NodeType = 205; Tag = 'MNU'; FilePrefix = 'Menu'; SubTag = ''}
    [xpoType]@{AOTpath = @('Data Dictionary', 'Table Collections'); OneLevelAOTPath ='Table Collections'; UtilType = 48; NodeType = 211; Tag = 'TCL'; FilePrefix = 'TableCollection'; SubTag = ''}
    [xpoType]@{AOTpath = @('Queries'); OneLevelAOTPath ='Queries'; UtilType = 20; NodeType = 330; Tag = 'QUE'; FilePrefix = 'Query'; SubTag = ''}
    [xpoType]@{AOTpath = @('Projects', 'Shared'); OneLevelAOTPath ='Shared Projects'; UtilType = 37; NodeType = 0; Tag = 'PRN'; FilePrefix = 'SharedProject'; SubTag = 'SHARED'}
    [xpoType]@{AOTpath = @('Projects', 'Private'); OneLevelAOTPath ='Private Projects'; UtilType = 38; NodeType = 0; Tag = 'PRN'; FilePrefix = 'Private'; SubTag = 'PRIVATE'}
    [xpoType]@{AOTpath = @('References'); OneLevelAOTPath ='References'; UtilType = 53; NodeType = 822; Tag = 'REF'; FilePrefix = 'Reference'; SubTag = ''}
    [xpoType]@{AOTpath = @('Reports'); OneLevelAOTPath ='Reports'; UtilType = 18; NodeType = 202; Tag = 'RG' ; FilePrefix = 'Report'; SubTag = ''}
    [xpoType]@{AOTpath = @('Report Libraries'); OneLevelAOTPath ='Report Libraries'; UtilType = 79; NodeType = 1426; Tag = 'RLB' ; FilePrefix = 'ReportLibrary'; SubTag = ''}
    [xpoType]@{AOTpath = @('Reports', 'Section Templates'); OneLevelAOTPath ='Report Section Templates'; UtilType = 27; NodeType = 86; Tag = 'RST'; FilePrefix = 'ReportSectionTemplate'; SubTag = ''}
    [xpoType]@{AOTpath = @('Reports', 'Report Templates'); OneLevelAOTPath ='Report Templates'; UtilType = 19; NodeType = 90; Tag = 'RGT'; FilePrefix = 'ReportTemplate'; SubTag = ''}
    [xpoType]@{AOTpath = @('Resources'); OneLevelAOTPath ='Resources'; UtilType = 21; NodeType = 820; Tag = 'RES'; FilePrefix = 'Resource'; SubTag = ''}
    [xpoType]@{AOTpath = @('Data Dictionary', 'Configuration Keys'); OneLevelAOTPath ='Configuration Keys'; UtilType = 39; NodeType = 312; Tag = 'CON'; FilePrefix = 'ConfigurationKey'; SubTag = ''}
    [xpoType]@{AOTpath = @('Data Dictionary', 'Security Keys'); OneLevelAOTPath ='Security Keys'; UtilType = 36; NodeType = 313; Tag = 'SEC'; FilePrefix = 'SecurityKey'; SubTag = ''}
    [xpoType]@{AOTpath = @('Data Sets'); OneLevelAOTPath ='Data Sets'; UtilType = 72; NodeType = 207; Tag = 'DST'; FilePrefix = 'DataSet'; SubTag = ''}
    [xpoType]@{AOTpath = @('Data Dictionary', 'License Codes'); OneLevelAOTPath ='License Codes'; UtilType = 15; NodeType = 311; Tag = 'LIC'; FilePrefix = 'LicenseCode'; SubTag = ''}
    [xpoType]@{AOTpath = @('Data Dictionary', 'Perspectives'); OneLevelAOTPath ='Perspectives'; UtilType = 66; NodeType = 1311; Tag = 'PRS'; FilePrefix = 'Perspective'; SubTag = ''}
    [xpoType]@{AOTpath = @('Services'); OneLevelAOTPath ='Services'; UtilType = 76; NodeType = 1321; Tag = 'SVC'; FilePrefix = 'Service'; SubTag = ''}
    [xpoType]@{AOTpath = @('Service Groups'); OneLevelAOTPath ='Service Groups'; UtilType = 137; NodeType = 1325; Tag = 'SVG'; FilePrefix = 'ServiceGroup'; SubTag = ''}
    
    [xpoType]@{AOTpath = @('Web', 'Menu Items', 'URL'); OneLevelAOTPath ='Web URL Items'; UtilType = 55; NodeType = 864; Tag = 'WMU'; FilePrefix = 'WebUrlItem'; SubTag = ''}
    [xpoType]@{AOTpath = @('Web', 'Menu Items', 'Actions'); OneLevelAOTPath ='Web Action Menu Items'; UtilType = 56; NodeType = 866; Tag = 'WMA'; FilePrefix = 'WebActionItem'; SubTag = ''}
    [xpoType]@{AOTpath = @('Web', 'Menus'); OneLevelAOTPath ='Web Menus'; UtilType = 30; NodeType = 806; Tag = 'WME'; FilePrefix = 'WebMenu'; SubTag = ''}
    [xpoType]@{AOTpath = @('Web', 'Forms'); OneLevelAOTPath ='Web Forms'; UtilType = 34; NodeType = 800; Tag = 'WFM'; FilePrefix = 'WebForm'; SubTag = ''}
    [xpoType]@{AOTpath = @('Web', 'Weblets'); OneLevelAOTPath ='Weblets'; UtilType = 59; NodeType = 873; Tag = 'WIT'; FilePrefix = 'WebletItem'; SubTag = ''}
    [xpoType]@{AOTpath = @('Web', 'Modules'); OneLevelAOTPath ='Web Modules'; UtilType = 67; NodeType = 885; Tag = 'WML'; FilePrefix = 'WebModule'; SubTag = ''}
    [xpoType]@{AOTpath = @('Web', 'Reports'); OneLevelAOTPath ='Web Reports'; UtilType = 52; NodeType = 203; Tag = 'WRG'; FilePrefix = 'WebReport'; SubTag = ''}
    [xpoType]@{AOTpath = @('Web', 'Files', 'List Definitions'); OneLevelAOTPath ='Web List Definitions'; UtilType = 78; NodeType = 892; Tag = 'WLD'; FilePrefix = 'WebListDef'; SubTag = ''}
    [xpoType]@{AOTpath = @('Web', 'Files', 'List Definitions'); OneLevelAOTPath ='Web Site Definitions'; UtilType = 61; NodeType = 877; Tag = 'WSD'; FilePrefix = 'WebSiteDef'; SubTag = ''}
    [xpoType]@{AOTpath = @('Web', 'Files', 'Web Controls'); OneLevelAOTPath ='Web Controls'; UtilType = 73; NodeType = 887; Tag = 'WCL'; FilePrefix = 'WebControl'; SubTag = ''}
    [xpoType]@{AOTpath = @('Web', 'Files', 'Page Definitions'); OneLevelAOTPath ='Web Page Definitions'; UtilType = 63; NodeType = 881; Tag = 'WPD'; FilePrefix = 'WebPageDef'; SubTag = ''}
    [xpoType]@{AOTpath = @('Web', 'Files', 'Site templates'); OneLevelAOTPath ='Web Site Templates'; UtilType = 62; NodeType = 879; Tag = 'WPD'; FilePrefix = 'WebSiteTemp'; SubTag = ''}
    [xpoType]@{AOTpath = @('Web', 'Web Content', 'Dispaly'); OneLevelAOTPath ='Web Display Content Items'; UtilType = 57; NodeType = 869; Tag = 'WCD'; FilePrefix = 'WebDisplayContentItem'; SubTag = ''}
    [xpoType]@{AOTpath = @('Web', 'Web Content', 'Output'); OneLevelAOTPath ='Web Output Content Items'; UtilType = 58; NodeType = 871; Tag = 'WCO'; FilePrefix = 'WebOutputContentItem'; SubTag = ''}
    [xpoType]@{AOTpath = @('Web', 'Web Content', 'Managed'); OneLevelAOTPath ='Web Managed Сontent Items'; UtilType = 75; NodeType = 890; Tag = 'WCM'; FilePrefix = 'WebManagedContentItem'; SubTag = ''}
    [xpoType]@{AOTpath = @('Web', 'Web Content', 'Static Files'); OneLevelAOTPath ='Web Static Files'; UtilType = 64; NodeType = 883; Tag = 'WRF'; FilePrefix = 'WebStaticFile'; SubTag = ''}
    [xpoType]@{AOTpath = @('Web', 'Web Content', 'Web Parts'); OneLevelAOTPath ='Web Parts'; UtilType = 60; NodeType = 875; Tag = 'WWP'; FilePrefix = 'WebPart'; SubTag = ''}
    [xpoType]@{AOTpath = @('Workflow', 'Templates'); OneLevelAOTPath ='Workflow Templates'; UtilType = 68; NodeType = 1412; Tag = 'WFL'; FilePrefix = 'WorkflowTemplate'; SubTag = ''}
    [xpoType]@{AOTpath = @('Workflow', 'Tasks'); OneLevelAOTPath ='Workflow Tasks'; UtilType = 69; NodeType = 1417; Tag = 'WFT'; FilePrefix = 'WorkflowTask'; SubTag = ''}
    [xpoType]@{AOTpath = @('Workflow', 'Approvals'); OneLevelAOTPath ='Workflow Approvals'; UtilType = 70; NodeType = 1421; Tag = 'WFA'; FilePrefix = 'WorkflowApproval'; SubTag = ''}
    [xpoType]@{AOTpath = @('Workflow', 'Categories'); OneLevelAOTPath ='Workflow Categories'; UtilType = 71; NodeType = 1423; Tag = 'WFC'; FilePrefix = 'WorkflowCategory'; SubTag = ''}
    [xpoType]@{AOTpath = @('Help Files'); OneLevelAOTPath ='Help Files'; UtilType = 65; NodeType = 1301; Tag = 'HPF'; FilePrefix = 'HelpFile'; SubTag = ''}

    #ax2012
    [xpoType]@{AOTpath = @('Parts', 'Info Parts'); OneLevelAOTPath ='Info Parts'; UtilType = 81; NodeType = 1429; Tag = 'IPA'; FilePrefix = 'InfoPart'; SubTag = ''}
    [xpoType]@{AOTpath = @('Parts', 'Form Parts'); OneLevelAOTPath ='Form Parts'; UtilType = 82; NodeType = 1431; Tag = 'FPA'; FilePrefix = 'FormPart'; SubTag = ''}
    [xpoType]@{AOTpath = @('Parts', 'Cues'); OneLevelAOTPath ='Cues'; UtilType = 98; NodeType = 1543; Tag = 'CUN'; FilePrefix = 'Cue'; SubTag = ''}
    [xpoType]@{AOTpath = @('Parts', 'Cue Groups'); OneLevelAOTPath ='Cue Groups'; UtilType = 99; NodeType = 1544; Tag = 'CGN'; FilePrefix = 'CueGroup'; SubTag = ''}
    #[xpoType]@{AOTpath = @('SSRS Reports', 'Reports Images'); OneLevelAOTPath ='SSRS Report Images'; UtilType = ; NodeType = 1450; Tag = ; FilePrefix = 'SSRSReportImage'; SubTag = ''}
    [xpoType]@{AOTpath = @('SSRS Reports', 'Reports Datasources'); OneLevelAOTPath ='SSRS Report Datasources'; UtilType = 93; NodeType = 1449; Tag = 'SDS'; FilePrefix = 'SSRSReportDataSource'; SubTag = ''}
    [xpoType]@{AOTpath = @('SSRS Reports', 'Report Style Templates', 'XY Chart Style Templates'); OneLevelAOTPath ='SSRS Report XY Chart Style Templates'; UtilType = 92; NodeType = 1448; Tag = 'SXT'; FilePrefix = 'SSRSReportXYChartStyleTemplate'; SubTag = ''}
    [xpoType]@{AOTpath = @('SSRS Reports', 'Report Style Templates', 'Table Style Templates'); OneLevelAOTPath ='SSRS Report Table Style Templates'; UtilType = 91; NodeType = 1447; Tag = 'STT'; FilePrefix = 'SSRSReportTableStyleTemplate'; SubTag = ''}
    [xpoType]@{AOTpath = @('SSRS Reports', 'Report Style Templates', 'Pie Chart Style Templates'); OneLevelAOTPath ='SSRS Report Pie Chart Style Templates'; UtilType = 90; NodeType = 1446; Tag = 'SPT'; FilePrefix = 'SSRSReportPieChartStyleTemplate'; SubTag = ''}
    [xpoType]@{AOTpath = @('SSRS Reports', 'Report Style Templates', 'Matrix Style Templates'); OneLevelAOTPath ='SSRS Report Matrix Style Templates'; UtilType = 89; NodeType = 1445; Tag = 'SMT'; FilePrefix = 'SSRSReportMatrixStyleTemplate'; SubTag = ''}
    [xpoType]@{AOTpath = @('SSRS Reports', 'Report Style Templates', 'List Style Templates'); OneLevelAOTPath ='SSRS Report List Style Templates'; UtilType = 88; NodeType = 1444; Tag = 'SLT'; FilePrefix = 'SSRSReportListStyleTemplate'; SubTag = ''}
    [xpoType]@{AOTpath = @('SSRS Reports', 'Report Style Templates', 'Layout Templates'); OneLevelAOTPath ='SSRS Report Layout Templates'; UtilType = 87; NodeType = 1443; Tag = 'SRL'; FilePrefix = 'SSRSReportLayoutTemplate'; SubTag = ''}
    [xpoType]@{AOTpath = @('SSRS Reports', 'Reports'); OneLevelAOTPath ='SSRS Reports'; UtilType = 85; NodeType = 1439; Tag = 'SRP'; FilePrefix = 'SSRSReport'; SubTag = ''}
    [xpoType]@{AOTpath = @('SSRS Reports', 'Report Style Templates', 'Matrix Style Templates'); OneLevelAOTPath ='SSRS Report Matrix Style Templates'; UtilType = 89; NodeType = 1445; Tag = 'SMT'; FilePrefix = 'SSRSReportMatrixStyleTemplate'; SubTag = ''}
    [xpoType]@{AOTpath = @('SSRS Reports', 'Report Style Templates', 'Matrix Style Templates'); OneLevelAOTPath ='SSRS Report Matrix Style Templates'; UtilType = 89; NodeType = 1445; Tag = 'SMT'; FilePrefix = 'SSRSReportMatrixStyleTemplate'; SubTag = ''}

    [xpoType]@{AOTpath = @('Visual Studio Projects', 'Dynamics AX Model Projects'); OneLevelAOTPath ='VSProject Dynamics AX Model Projects'; UtilType = 127; NodeType = 1531; Tag = 'VPY'; FilePrefix = 'VSProject_AXModel'; SubTag = ''}
    [xpoType]@{AOTpath = @('Visual Studio Projects', 'C Sharp Projects'); OneLevelAOTPath ='VSProject C Sharp Projects'; UtilType = 128; NodeType = 1531; Tag = 'VPC'; FilePrefix = 'VSProject_CSharp'; SubTag = ''}
    #[xpoType]@{AOTpath = @('Visual Studio Projects', 'Visual Basic Projects'); OneLevelAOTPath ='VSProject Visual Basic Projects'; UtilType = 129; NodeType = 1531; Tag = ; FilePrefix = 'VSProject_VB'; SubTag = ''}
    #[xpoType]@{AOTpath = @('Visual Studio Projects', 'Web Application Projects'); OneLevelAOTPath ='VSProject Web Application Projects'; UtilType = 130; NodeType = 1531; Tag = ; FilePrefix = 'VSProject_WebApplication'; SubTag = ''}
    [xpoType]@{AOTpath = @('Visual Studio Projects', 'Analysis Services Projects'); OneLevelAOTPath ='VSProject Analysis Projects'; UtilType = 131; NodeType = 1531; Tag = 'VPY'; FilePrefix = 'VSProject_Analysis'; SubTag = ''}

    [xpoType]@{AOTpath = @('Workflow', 'Automated Tasks'); OneLevelAOTPath ='Workflow Automated Tasks'; UtilType = 95; NodeType = 1409; Tag = 'WFN'; FilePrefix = 'WorkflowAutomatedTask'; SubTag = ''}
    [xpoType]@{AOTpath = @('Workflow', 'Providers', 'Hierarchy Assignment'); OneLevelAOTPath ='Workflow Hierarchy Assignment Providers'; UtilType = 139; NodeType = 1397; Tag = 'WFH'; FilePrefix = 'WorkflowHierarchyProvider'; SubTag = ''}
    [xpoType]@{AOTpath = @('Workflow', 'Providers', 'Participant Assignment'); OneLevelAOTPath ='Workflow Participant Assignment Providers'; UtilType = 140; NodeType = 1399; Tag = 'WFP'; FilePrefix = 'WorkflowParticipantProvider'; SubTag = ''}
    [xpoType]@{AOTpath = @('Workflow', 'Providers', 'Analysis Queue Assignment'); OneLevelAOTPath ='Workflow Queue Providers'; UtilType = 141; NodeType = 1401; Tag = 'WFQ'; FilePrefix = 'WorkflowQueueProvider'; SubTag = ''}
    [xpoType]@{AOTpath = @('Workflow', 'Providers', 'Due Date Calculation'); OneLevelAOTPath ='Workflow Due Date Providers'; UtilType = 142; NodeType = 1403; Tag = 'WFD'; FilePrefix = 'WorkflowDueDateProvider'; SubTag = ''}

    [xpoType]@{AOTpath = @('Security', 'Code Permissions'); OneLevelAOTPath ='Security Code Permissions'; UtilType = 115; NodeType = 1608; Tag = 'SCP'; FilePrefix = 'SecCodePermission'; SubTag = ''}
    [xpoType]@{AOTpath = @('Security', 'Privileges'); OneLevelAOTPath ='Security Privileges'; UtilType = 134; NodeType = 1628; Tag = 'SPV'; FilePrefix = 'SecPrivilege'; SubTag = ''}
    [xpoType]@{AOTpath = @('Security', 'Duties'); OneLevelAOTPath ='Security Duties'; UtilType = 135; NodeType = 1630; Tag = 'SDT'; FilePrefix = 'SecDuty'; SubTag = ''}
    [xpoType]@{AOTpath = @('Security', 'Roles'); OneLevelAOTPath ='Security Roles'; UtilType = 133; NodeType = 1626; Tag = 'SRO'; FilePrefix = 'SecRole'; SubTag = ''}
    [xpoType]@{AOTpath = @('Security', 'Process Cycles'); OneLevelAOTPath ='Security Process Cycles'; UtilType = 136; NodeType = 1636; Tag = 'SPC'; FilePrefix = 'SecProcessCycle'; SubTag = ''}
    [xpoType]@{AOTpath = @('Security', 'Policies'); OneLevelAOTPath ='Security Policies'; UtilType = 119; NodeType = 1619; Tag = 'SPO'; FilePrefix = 'SecPolicy'; SubTag = ''}

    [xpoType]@{AOTpath = @('Label Files'); OneLevelAOTPath ='Label Files'; UtilType = 117; NodeType = 831; Tag = 'LBL'; FilePrefix = 'LabelFile'; SubTag = ''}
    [xpoType]@{AOTpath = @('Help Document Sets'); OneLevelAOTPath ='Help Document Sets'; UtilType = 101; NodeType = 1527; Tag = 'DCS'; FilePrefix = 'DocSet'; SubTag = ''}

    #ax30
    [xpoType]@{AOTpath = @('Data Dictionary', 'Feature keys'); OneLevelAOTPath ='Feature keys'; UtilType = 39; NodeType = 237; Tag = 'FСС'; FilePrefix = 'FeatureKey'; SubTag = ''}

)

function Get-XpoType {
    [CmdletBinding(DefaultParameterSetName = "NodeType")]
    [OutputType([xpoType])]
    param (
        [Parameter(Position = 0, ParameterSetName = "xpoItem", ValueFromPipeline)]
        [xpoItem]$xpoItem,

        [Parameter(Position = 0, ParameterSetName = "xpoNode", ValueFromPipeline)]
        [xpoNode]$xpoNode,

        [Parameter(Position = 0, ParameterSetName = "NodeType", ValueFromPipeline)]
        [int]$NodeType,

        [Parameter(Position = 0, ParameterSetName = "UtilType", ValueFromPipeline)]
        [int]$UtilType,

        [Parameter(Position = 0, ParameterSetName = "Tag", ValueFromPipeline)]
        [Parameter(Position = 0, ParameterSetName = "SubTag")]
        [string]$Tag,

        [Parameter(Position = 1, ParameterSetName = "SubTag")]
        [string]$SubTag
    )

    process {
        switch ($PSCmdlet.ParameterSetName) {
            'xpoItem' { $script:xpoTypeInfo | Where-Object { $_ -eq $xpoItem } | Select-Object -First 1 }
            'xpoNode' { $script:xpoTypeInfo | Where-Object { $_ -eq $xpoNode } | Select-Object -First 1 }
            'SubTag' { $script:xpoTypeInfo | Where-Object { ($_.Tag -EQ $Tag) -and ($_.SubTag -EQ $SubTag) } | Select-Object -First 1 }
            'Tag' { $script:xpoTypeInfo | Where-Object { $_.Tag -EQ $Tag } }
            'NodeType' { $script:xpoTypeInfo | Where-Object { $_.NodeType -EQ $NodeType } }
            'UtilType' { $script:xpoTypeInfo | Where-Object { $_.UtilType -EQ $UtilType } }
        }
    }
}