functions/invoke-d365sysrunnerclass.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

<#
    .SYNOPSIS
        Start a browser session that executes SysRunnerClass
         
    .DESCRIPTION
        Makes it possible to call any runnable class directly from the browser, without worrying about the details
         
    .PARAMETER ClassName
        The name of the class you want to execute
         
    .PARAMETER Company
        The company for which you want to execute the class against
         
        Default value is: "DAT"
         
    .PARAMETER Url
        The URL you want to execute against
         
        Default value is the Fully Qualified Domain Name registered on the machine
         
    .EXAMPLE
        PS C:\> Invoke-D365SysRunnerClass -ClassName SysFlushAOD
         
        Will execute the SysRunnerClass and have it execute the SysFlushAOD class and will run it against the "DAT" (default value) company
         
    .EXAMPLE
        PS C:\> Invoke-D365SysRunnerClass -ClassName SysFlushAOD -Company "USMF"
         
        Will execute the SysRunnerClass and have it execute the SysFlushAOD class and will run it against the "USMF" company
         
    .EXAMPLE
        PS C:\> Invoke-D365SysRunnerClass -ClassName SysFlushAOD -Url https://Test.cloud.onebox.dynamics.com
         
        Will execute the SysRunnerClass and have it execute the SysFlushAOD class and will run it against the "DAT" company, on the https://Test.cloud.onebox.dynamics.com URL
         
    .NOTES
        Author: Mötz Jensen (@Splaxi)
         
#>

function Invoke-D365SysRunnerClass {
    [CmdletBinding(DefaultParameterSetName = 'Default')]
    param (
        [Parameter(Mandatory = $true, ParameterSetName = 'Default', Position = 1 )]
        [string] $ClassName,

        [Parameter(Mandatory = $false, ParameterSetName = 'Default', Position = 2 )]
        
        [string] $Company = $Script:Company,
        [Parameter(Mandatory = $false, ParameterSetName = 'Default', Position = 3 )]
        [string] $Url = $Script:Url
    )

    $executingUrl = "$Url`?cmp=$Company&mi=SysClassRunner&cls=$ClassName"

    Start-Process $executingUrl
}