internal/functions/get-autorunxml.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80

<#
    .SYNOPSIS
        Get the autorun xml element
         
    .DESCRIPTION
        Get the correct autorun xml element based on the action that you want to perform
         
    .PARAMETER Action
        The action name that you want to execute when running the autorun feature of the AX 2012 Client
         
        Valid options are:
        "CompileCilFull"
        "CompileCilIncremental"
        "CompileXpp"
        "CompileXppAndXRef"
        "SynchronizeDB"
         
    .EXAMPLE
        PS C:\> Get-AutoRunXML -Action "SynchronizeDB"
         
        This will return the correct XML element for "SynchronizeDB".
         
    .NOTES
        Tags:
         
        Author: Mötz Jensen (@Splaxi)
         
        #https://docs.microsoft.com/en-us/previous-versions/dynamics/ax-2012/application-classes/gg922801%28v%3dax.60%29
#>


function Get-AutoRunXML {
    [CmdletBinding()]
    param(
        [Parameter(Mandatory = $true)]
        [String] $Action
    )
     
    $res = ""

    switch ($Action) {
        "SynchronizeDB" {
            $res = '<Synchronize syncDb="true"/>'
            # $element = $xml.CreateElement('Synchronize')
            # $element.SetAttribute("syncDb", "true")
        }

        "SynchronizeRoles" {
            # $res = '<Synchronize "syncDb"="true"/>'
            # $element = $xml.CreateElement('Synchronize')
            # $element.SetAttribute("syncRoles", "true")
        }

        "CompileCilFull" {
            $res = '<CompileIL incremental="false"/>'
            # $element = $xml.CreateElement('CompileIL')
            # $element.SetAttribute("incremental", "false")
        }

        "CompileCilIncremental" {
            $res = '<CompileIL incremental="true"/>'
            # $element = $xml.CreateElement('CompileIL')
            # $element.SetAttribute("incremental", "true")
        }

        "CompileXpp" {
            $res = '<CompileApplication crossReference="false"/>'
            # $element = $xml.CreateElement('CompileApplication')
            # $element.SetAttribute("crossReference", "false")
        }

        "CompileXppAndXRef" {
            $res = '<CompileApplication crossReference="true"/>'
            # $element = $xml.CreateElement('CompileApplication')
            # $element.SetAttribute("crossReference", "true")
        }
    }

    $res
}