resourcesAfter.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<#
This is an example configuration file
 
By default, it is enough to have a single one of them,
however if you have enough configuration settings to justify having multiple copies of it,
feel totally free to split them into multiple files.
#>


<#
# Example Configuration
Set-PSFConfig -Module 'ax2012.tools' -Name 'Example.Setting' -Value 10 -Initialize -Validation 'integer' -Handler { } -Description "Example configuration setting. Your module can then use the setting using 'Get-PSFConfigValue'"
#>


Set-PSFConfig -Module 'ax2012.tools' -Name 'Import.DoDotSource' -Value $false -Initialize -Validation 'bool' -Description "Whether the module files should be dotsourced on import. By default, the files of this module are read as string value and invoked, which is faster but worse on debugging."
Set-PSFConfig -Module 'ax2012.tools' -Name 'Import.IndividualFiles' -Value $false -Initialize -Validation 'bool' -Description "Whether the module files should be imported individually. During the module build, all module code is compiled into few files, which are imported instead by default. Loading the compiled versions is faster, using the individual files is easier for debugging and testing out adjustments."

Set-PSFConfig -Module 'ax2012.tools' -Name 'active.aos.computername' -Value "" -Initialize -Description "The computername on which the specific AOS instance is running."
Set-PSFConfig -Module 'ax2012.tools' -Name 'active.aos.bindirectory' -Value "" -Initialize -Description "The path to the bin directory where the AOS instance is installed."
Set-PSFConfig -Module 'ax2012.tools' -Name 'active.aos.instance.number' -Value "" -Initialize -Description "The registered instance number the AOS has on the specific machine."
Set-PSFConfig -Module 'ax2012.tools' -Name 'active.aos.instancename' -Value "" -Initialize -Description "The registered instance name the AOS has on the specific machine."
Set-PSFConfig -Module 'ax2012.tools' -Name 'active.aos.databaseserver' -Value "" -Initialize -Description "The registered SQL Server the AOS is communicating with."
Set-PSFConfig -Module 'ax2012.tools' -Name 'active.aos.database' -Value "" -Initialize -Description "The registered database the AOS is saving all its data."
Set-PSFConfig -Module 'ax2012.tools' -Name 'active.aos.modelstoredatabase' -Value "" -Initialize -Description "The registered modelstore database the AOS is storing all its code."
Set-PSFConfig -Module 'ax2012.tools' -Name 'active.aos.aos.port' -Value "" -Initialize -Description "The registered port the AOS is listing for clients on."
Set-PSFConfig -Module 'ax2012.tools' -Name 'active.aos.wsdl.port' -Value "" -Initialize -Description "The registered WSDL port the AOS is exposing WSDL services on."
Set-PSFConfig -Module 'ax2012.tools' -Name 'active.aos.nettcp.port' -Value "" -Initialize -Description "The registered NetTcp port the AOS is exposing Custom services on."

Set-PSFConfig -Module 'ax2012.tools' -Name 'active.logicapp.email' -Value "" -Initialize -Description "The registered email address the Invoke-AxLogicApp should notify when firing a notification request."
Set-PSFConfig -Module 'ax2012.tools' -Name 'active.logicapp.url' -Value "" -Initialize -Description "The registered URL/URI the Invoke-AxLogicApp should contact when firing a notification request."
Set-PSFConfig -Module 'ax2012.tools' -Name 'active.logicapp.subject' -Value "" -Initialize -Description "The registered subject the Invoke-AxLogicApp should use as context when firing a notification request."

Set-PSFConfig -FullName "ax2012.tools.active.environment.config.name" -Value "" -Initialize -Description "Name of the environment configuration that should be the default / active configuration for the module."

Register-PSFTeppScriptblock -Name "ax2012.client.cache.objects" -ScriptBlock { 'auc', 'kti', 'VSAssemblies'}
Register-PSFTeppScriptblock -Name "ax2012.client.cache.user.location" -ScriptBlock { 'CurrentUser', 'AllUsers'}

Register-PSFTeppScriptblock -Name "ax2012.server.cache.objects" -ScriptBlock { 'XppIL', 'Label', 'VSAssemblies'}


<#
# Example:
Register-PSFTeppScriptblock -Name "ax2012.tools.alcohol" -ScriptBlock { 'Beer','Mead','Whiskey','Wine','Vodka','Rum (3y)', 'Rum (5y)', 'Rum (7y)' }
#>


<#
# Example:
Register-PSFTeppArgumentCompleter -Command Get-Alcohol -Parameter Type -Name ax2012.tools.alcohol
#>


Register-PSFTeppArgumentCompleter -Command Clear-AxClientCacheObjects -Parameter ObjectType -Name ax2012.client.cache.objects
Register-PSFTeppArgumentCompleter -Command Clear-AxClientCacheObjects -Parameter UserLocation -Name ax2012.client.cache.user.location

Register-PSFTeppArgumentCompleter -Command Clear-AxServerCacheObjects -Parameter ObjectType -Name ax2012.server.cache.objects



New-PSFLicense -Product 'ax2012.tools' -Manufacturer 'Motz' -ProductVersion $script:ModuleVersion -ProductType Module -Name MIT -Version "1.0.0.0" -Date (Get-Date "2018-10-03") -Text @"
Copyright (c) 2018 Motz
 
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
 
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
 
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"@


$Script:TimeSignals = @{}

Write-PSFMessage -Level Verbose -Message "Gathering all variables to assist the different cmdlets to function" -FunctionName "Variables.ps1"

$Script:IsAdminRuntime = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)

$Script:AxPowerShellModule = "C:\Program Files\Microsoft Dynamics AX\60\ManagementUtilities\Microsoft.Dynamics.ManagementUtilities.ps1"

$Script:RegistryAos = "HKLM:\SYSTEM\ControlSet001\Services\Dynamics Server\6.0"

# This will give us the current AX 2012 Client Config for current signed in user
$Script:RegistryClientConfig = "HKCU:\Software\Microsoft\Dynamics\6.0\Configuration"
$Script:RegistryClient = "HKLM:\SOFTWARE\Microsoft\Dynamics\6.0\Setup"

$Script:RegistryMr2012 = "HKLM:\SOFTWARE\Microsoft\Dynamics\ManagementReporter\21\Server"

$Script:Mr2012DeploymentLogsPath = "C:\ProgramData\Microsoft Dynamics ERP\Management Reporter\Logs"
$Script:Mr2012ConfigPath = "Services\MRServiceHost.connections.config"
$Script:Mr2012ServiceConfigPath = "Services\MRServiceHost.settings.config"

$Script:LayerDictionary = @{"ISV" = "01."; "ISP" = "02."; "VAR" = "03."; "VAP" = "04."; "CUS" = "05."; "CUP" = "06."; "USR" = "07." ; "USP" = "08."}

$Script:ClientBin = Get-ClientBinDir

#Microsoft.Dynamics.BusinessConnectorNet.dll

$Script:DefaultTempPath = "c:\temp\ax2012.tools"

Update-ActiveEnvironmentVariables

Update-ActiveVariables

# ActiveAosAosPort -
# ActiveAosBindirectory -
# ActiveAosComputername -
# ActiveAosDatabase -
# ActiveAosInstancename -
# ActiveAosInstanceNumber -
# ActiveAosModelstoredatabase -
# ActiveAosNettcpPort -
# ActiveAosWsdlPort -

$maskOutput = @(
    "AccessToken"
)

(Get-Variable -Scope Script) | ForEach-Object {
    $val = $null

    if ($maskOutput -contains $($_.Name)) {
        $val = "The variable was found - but the content masked while outputting."
    }
    else {
        $val = $($_.Value)
    }
   
    Write-PSFMessage -Level Verbose -Message "$($_.Name) - $val" -Target $val -FunctionName "Variables.ps1"
}

Write-PSFMessage -Level Verbose -Message "Finished outputting all the variable content." -FunctionName "Variables.ps1"