From 83265b490820e256f08741c2ea176715f5eb0ade Mon Sep 17 00:00:00 2001 From: FH-Inway Date: Sun, 8 Oct 2023 15:21:17 +0000 Subject: [PATCH] 'Update comment based help and tests This pull request was automatically created by the d365fo.tools-Generate-Text action' --- d365fo.tools/functions/import-d365bacpac.ps1 | 6 ++-- .../functions/Import-D365Bacpac.Tests.ps1 | 19 ++++++++-- docs/Import-D365Bacpac.md | 35 +++++++++++++++++-- 3 files changed, 51 insertions(+), 9 deletions(-) diff --git a/d365fo.tools/functions/import-d365bacpac.ps1 b/d365fo.tools/functions/import-d365bacpac.ps1 index d367288f..98389379 100644 --- a/d365fo.tools/functions/import-d365bacpac.ps1 +++ b/d365fo.tools/functions/import-d365bacpac.ps1 @@ -102,7 +102,7 @@ .PARAMETER EnableException This parameters disables user-friendly warnings and enables the throwing of exceptions This is less user friendly, but allows catching exceptions in calling scripts - + .PARAMETER Properties String array of properties to be used by SQLPackage.exe See https://learn.microsoft.com/en-us/sql/tools/sqlpackage/sqlpackage-import#properties-specific-to-the-import-action for more information. @@ -159,12 +159,12 @@ This would be something that you can use when extract a bacpac file from a Tier1 and want to import it into a Tier1. You would still need to execute the Switch-D365ActiveDatabase cmdlet, to get the newly imported database to be the AXDB database. - + .EXAMPLE PS C:\> [System.Collections.ArrayList] $PropertiesList = New-Object -TypeName "System.Collections.ArrayList" PS C:\> $PropertiesList.Add("DisableIndexesForDataPhase=false") PS C:\> Import-D365Bacpac -ImportModeTier1 -BacpacFile "C:\temp\uat.bacpac" -NewDatabaseName "ImportedDatabase" -Properties $PropertiesList.ToArray() - + This will instruct the cmdlet that the import will be working against a SQL Server instance. It will import the "C:\temp\uat.bacpac" file into a new database named "ImportedDatabase". It will use the DisableIndexesForDataPhase SQLPackage property to disable the index rebuild during the data phase of the import. diff --git a/d365fo.tools/tests/functions/Import-D365Bacpac.Tests.ps1 b/d365fo.tools/tests/functions/Import-D365Bacpac.Tests.ps1 index a54d0d18..cf5194b1 100644 --- a/d365fo.tools/tests/functions/Import-D365Bacpac.Tests.ps1 +++ b/d365fo.tools/tests/functions/Import-D365Bacpac.Tests.ps1 @@ -413,24 +413,37 @@ $parameter.ParameterSets['__AllParameterSets'].ValueFromPipelineByPropertyName | Should -Be $False $parameter.ParameterSets['__AllParameterSets'].ValueFromRemainingArguments | Should -Be $False } + It 'Should have the expected parameter Properties' { + $parameter = (Get-Command Import-D365Bacpac).Parameters['Properties'] + $parameter.Name | Should -Be 'Properties' + $parameter.ParameterType.ToString() | Should -Be System.String[] + $parameter.IsDynamic | Should -Be $False + $parameter.ParameterSets.Keys | Should -Be '__AllParameterSets' + $parameter.ParameterSets.Keys | Should -Contain '__AllParameterSets' + $parameter.ParameterSets['__AllParameterSets'].IsMandatory | Should -Be $False + $parameter.ParameterSets['__AllParameterSets'].Position | Should -Be -2147483648 + $parameter.ParameterSets['__AllParameterSets'].ValueFromPipeline | Should -Be $False + $parameter.ParameterSets['__AllParameterSets'].ValueFromPipelineByPropertyName | Should -Be $False + $parameter.ParameterSets['__AllParameterSets'].ValueFromRemainingArguments | Should -Be $False + } } Describe "Testing parameterset ImportTier1" { <# ImportTier1 -ImportModeTier1 -BacpacFile -NewDatabaseName - ImportTier1 -ImportModeTier1 -DatabaseServer -DatabaseName -SqlUser -SqlPwd -BacpacFile -NewDatabaseName -CustomSqlFile -ModelFile -DiagnosticFile -ImportOnly -MaxParallelism -LogPath -ShowOriginalProgress -OutputCommandOnly -EnableException + ImportTier1 -ImportModeTier1 -DatabaseServer -DatabaseName -SqlUser -SqlPwd -BacpacFile -NewDatabaseName -CustomSqlFile -ModelFile -DiagnosticFile -ImportOnly -MaxParallelism -LogPath -ShowOriginalProgress -OutputCommandOnly -EnableException -Properties #> } Describe "Testing parameterset ImportOnlyTier2" { <# ImportOnlyTier2 -ImportModeTier2 -SqlUser -SqlPwd -BacpacFile -NewDatabaseName -ImportOnly - ImportOnlyTier2 -ImportModeTier2 -DatabaseServer -DatabaseName -SqlUser -SqlPwd -BacpacFile -NewDatabaseName -AxDeployExtUserPwd -AxDbAdminPwd -AxRuntimeUserPwd -AxMrRuntimeUserPwd -AxRetailRuntimeUserPwd -AxRetailDataSyncUserPwd -AxDbReadonlyUserPwd -CustomSqlFile -ModelFile -DiagnosticFile -ImportOnly -MaxParallelism -LogPath -ShowOriginalProgress -OutputCommandOnly -EnableException + ImportOnlyTier2 -ImportModeTier2 -DatabaseServer -DatabaseName -SqlUser -SqlPwd -BacpacFile -NewDatabaseName -AxDeployExtUserPwd -AxDbAdminPwd -AxRuntimeUserPwd -AxMrRuntimeUserPwd -AxRetailRuntimeUserPwd -AxRetailDataSyncUserPwd -AxDbReadonlyUserPwd -CustomSqlFile -ModelFile -DiagnosticFile -ImportOnly -MaxParallelism -LogPath -ShowOriginalProgress -OutputCommandOnly -EnableException -Properties #> } Describe "Testing parameterset ImportTier2" { <# ImportTier2 -ImportModeTier2 -SqlUser -SqlPwd -BacpacFile -NewDatabaseName -AxDeployExtUserPwd -AxDbAdminPwd -AxRuntimeUserPwd -AxMrRuntimeUserPwd -AxRetailRuntimeUserPwd -AxRetailDataSyncUserPwd -AxDbReadonlyUserPwd - ImportTier2 -ImportModeTier2 -DatabaseServer -DatabaseName -SqlUser -SqlPwd -BacpacFile -NewDatabaseName -AxDeployExtUserPwd -AxDbAdminPwd -AxRuntimeUserPwd -AxMrRuntimeUserPwd -AxRetailRuntimeUserPwd -AxRetailDataSyncUserPwd -AxDbReadonlyUserPwd -CustomSqlFile -ModelFile -DiagnosticFile -MaxParallelism -LogPath -ShowOriginalProgress -OutputCommandOnly -EnableException + ImportTier2 -ImportModeTier2 -DatabaseServer -DatabaseName -SqlUser -SqlPwd -BacpacFile -NewDatabaseName -AxDeployExtUserPwd -AxDbAdminPwd -AxRuntimeUserPwd -AxMrRuntimeUserPwd -AxRetailRuntimeUserPwd -AxRetailDataSyncUserPwd -AxDbReadonlyUserPwd -CustomSqlFile -ModelFile -DiagnosticFile -MaxParallelism -LogPath -ShowOriginalProgress -OutputCommandOnly -EnableException -Properties #> } diff --git a/docs/Import-D365Bacpac.md b/docs/Import-D365Bacpac.md index eee7f121..3d0952da 100644 --- a/docs/Import-D365Bacpac.md +++ b/docs/Import-D365Bacpac.md @@ -18,7 +18,7 @@ Import-D365Bacpac [-ImportModeTier1] [[-DatabaseServer] ] [[-DatabaseNam [[-SqlUser] ] [[-SqlPwd] ] [-BacpacFile] [-NewDatabaseName] [-CustomSqlFile ] [-ModelFile ] [-DiagnosticFile ] [-ImportOnly] [-MaxParallelism ] [-LogPath ] [-ShowOriginalProgress] [-OutputCommandOnly] [-EnableException] - [] + [-Properties ] [] ``` ### ImportOnlyTier2 @@ -29,7 +29,7 @@ Import-D365Bacpac [-ImportModeTier2] [[-DatabaseServer] ] [[-DatabaseNam [[-AxMrRuntimeUserPwd] ] [[-AxRetailRuntimeUserPwd] ] [[-AxRetailDataSyncUserPwd] ] [[-AxDbReadonlyUserPwd] ] [-CustomSqlFile ] [-ModelFile ] [-DiagnosticFile ] [-ImportOnly] [-MaxParallelism ] [-LogPath ] [-ShowOriginalProgress] [-OutputCommandOnly] - [-EnableException] [] + [-EnableException] [-Properties ] [] ``` ### ImportTier2 @@ -40,7 +40,7 @@ Import-D365Bacpac [-ImportModeTier2] [[-DatabaseServer] ] [[-DatabaseNam [-AxMrRuntimeUserPwd] [-AxRetailRuntimeUserPwd] [-AxRetailDataSyncUserPwd] [-AxDbReadonlyUserPwd] [-CustomSqlFile ] [-ModelFile ] [-DiagnosticFile ] [-MaxParallelism ] [-LogPath ] [-ShowOriginalProgress] [-OutputCommandOnly] [-EnableException] - [] + [-Properties ] [] ``` ## DESCRIPTION @@ -114,6 +114,18 @@ No cleanup or prepping jobs will be executed, because this is for importing only This would be something that you can use when extract a bacpac file from a Tier1 and want to import it into a Tier1. You would still need to execute the Switch-D365ActiveDatabase cmdlet, to get the newly imported database to be the AXDB database. +### EXAMPLE 7 +``` +[System.Collections.ArrayList] $PropertiesList = New-Object -TypeName "System.Collections.ArrayList" +``` + +PS C:\\\> $PropertiesList.Add("DisableIndexesForDataPhase=false") +PS C:\\\> Import-D365Bacpac -ImportModeTier1 -BacpacFile "C:\temp\uat.bacpac" -NewDatabaseName "ImportedDatabase" -Properties $PropertiesList.ToArray() + +This will instruct the cmdlet that the import will be working against a SQL Server instance. +It will import the "C:\temp\uat.bacpac" file into a new database named "ImportedDatabase". +It will use the DisableIndexesForDataPhase SQLPackage property to disable the index rebuild during the data phase of the import. + ## PARAMETERS ### -ImportModeTier1 @@ -622,6 +634,23 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -Properties +String array of properties to be used by SQLPackage.exe +See https://learn.microsoft.com/en-us/sql/tools/sqlpackage/sqlpackage-import#properties-specific-to-the-import-action for more information. +Note that some properties are already set by the cmdlet, and cannot be overridden. + +```yaml +Type: String[] +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### CommonParameters This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).