Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions d365bap.tools/d365bap.tools.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
, 'Get-BapEnvironmentApplicationUser'
, 'Get-BapEnvironmentD365App'
, 'Get-BapEnvironmentLinkEnterprisePolicy'
, 'Get-BapEnvironmentOperation'
, 'Get-BapEnvironmentPowerApp'
, 'Get-BapEnvironmentSecurityRole'
, 'Get-BapEnvironmentSecurityRoleMember'
Expand All @@ -75,20 +76,28 @@
, 'Get-UdeDbJit'
, 'Get-UdeDbJitCache'
, 'Get-UdeDeveloperFile'
, 'Get-UdeEnvironmentModule'
, 'Get-UdeEnvironmentOperationHistory'
, 'Get-UdeEnvironmentPackage'
, 'Get-UdeVsPackageDeploy'
, 'Get-UdeVsPowerPlatformExtensionHistory'
, 'Get-UdeXrefDb'

, 'Invoke-BapEnvironmentInstallD365App'
, 'Invoke-BapInstallAzCopy'

, 'Set-BapAzCopyPath'
, 'Set-BapEnvironmentLinkEnterprisePolicy'
, 'Set-BapEnvironmentSecurityGroup'
, 'Set-BapEnvironmentSecurityRoleMember'
, 'Set-BapEnvironmentVirtualEntity'
, 'Set-BapTenantDetail'

, 'Set-UdeConfig'
, 'Set-UdeDbJitCache'
, 'Set-UdeEnvironmentInSession'

, 'Start-BapDatabaseRefresh'
, 'Start-UdeDbSsms'
, 'Switch-BapTenant'

Expand Down
8 changes: 4 additions & 4 deletions d365bap.tools/functions/Add-UdeWindowsDefenderRules.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,19 @@ function Add-UdeWindowsDefenderRules {

if ($DefenderEnabled -eq $false) {
$messageString = "Windows Defender is <c='em'>NOT</c> enabled on this machine."
Write-PSFMessage -Level Host -Message $messageString
Write-PSFMessage -Level Important -Message $messageString
Stop-PSFFunction -Message "Stopping because Windows Defender is turned off." -Exception $([System.Exception]::new($($messageString -replace '<[^>]+>', '')))
return
}

if ($Force -and (-not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator))) {
Start-Process pwsh -Verb RunAs -ArgumentList "-NoExit", "-Command", "cd '$pwd'; Import-Module d365bap.tools; Add-UdeWindowsDefenderRules -Force"
Start-Process pwsh -Verb RunAs -ArgumentList "-NoExit", "-Command", "cd '$pwd'; Import-Module d365bap.tools; Add-UdeWindowsDefenderRules"
exit
}

if ((-not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator))) {
$messageString = "The current PowerShell session is <c='em'>NOT</c> running with elevated (Administrator) privileges. Please run this function with the <c='em'>-Force</c> or start a new PowerShell session as Administrator."
Write-PSFMessage -Level Host -Message $messageString
Write-PSFMessage -Level Important -Message $messageString
Stop-PSFFunction -Message "Stopping because Windows Defender is turned off." -Exception $([System.Exception]::new($($messageString -replace '<[^>]+>', '')))
return
}
Expand Down Expand Up @@ -128,7 +128,7 @@ function Add-UdeWindowsDefenderRules {
Add-MpPreference -ExclusionExtension "netmodule"
}
catch {
Write-PSFMessage -Level Host -Message "Something went wrong while configuring Windows Defender rules." -Exception $PSItem.Exception
Write-PSFMessage -Level Important -Message "Something went wrong while configuring Windows Defender rules." -Exception $PSItem.Exception
Stop-PSFFunction -Message "Stopping because of errors"
return
}
Expand Down
2 changes: 1 addition & 1 deletion d365bap.tools/functions/Clear-UdeCredentialCache.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function Clear-UdeCredentialCache {
if (-not $Force) {
$messageString = "This will remove all Visual Studio cached credentials for connecting to Dynamics 365 / Power Platform environments. If you are sure, please re-run the command with the <c='em'>-Force</c> parameter."

Write-PSFMessage -Level Host -Message $messageString -Target Host
Write-PSFMessage -Level Important -Message $messageString
Stop-PSFFunction -Message "Stopping because Force parameter wasn't supplied." -Exception $([System.Exception]::new($($messageString -replace '<[^>]+>', '')))
return
}
Expand Down
2 changes: 1 addition & 1 deletion d365bap.tools/functions/Clear-UdeDbJitCache.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function Clear-UdeDbJitCache {

begin {
if ($null -eq (Get-Module TUN.CredentialManager -ListAvailable)) {
Write-PSFMessage -Level Host -Message "This cmdlet needs the <c='em'>TUN.CredentialManager</c> module. Please install it from the PowerShell Gallery with <c='em'>Install-Module -Name TUN.CredentialManager</c> and try again."
Write-PSFMessage -Level Important -Message "This cmdlet needs the <c='em'>TUN.CredentialManager</c> module. Please install it from the PowerShell Gallery with <c='em'>Install-Module -Name TUN.CredentialManager</c> and try again."
Stop-PSFFunction -Message "Stopping because the TUN.CredentialManager module is not available."

return
Expand Down
14 changes: 7 additions & 7 deletions d365bap.tools/functions/Clear-UdeOrphanedConfig.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -118,24 +118,24 @@ function Clear-UdeOrphanedConfig {
} | Select-Object -ExpandProperty Name

if ($orphanedDirs.Count -lt 1 -and $orphanedXRefDbs.Count -lt 1) {
Write-PSFMessage -Level Host -Message "No orphaned UDE directories or XRef databases found. <c='em'>Nothing to do.</c>"
Write-PSFMessage -Level Important -Message "No orphaned UDE directories or XRef databases found. <c='em'>Nothing to do.</c>"
return
}

if (-not $Force) {
if ($orphanedDirs.Count -gt 0) {
Write-PSFMessage -Level Host -Message "The following directories are orphaned and will be removed:"
$orphanedDirs.ToArray() | ForEach-Object { Write-PSFMessage -Level Host -Message " - <c='em'>$_</c>" }
Write-PSFMessage -Level Important -Message "The following directories are orphaned and will be removed:"
$orphanedDirs.ToArray() | ForEach-Object { Write-PSFMessage -Level Important -Message " - <c='em'>$_</c>" }
}

if ($orphanedXRefDbs.Count -gt 0) {
Write-PSFMessage -Level Host -Message "The following XRef databases are orphaned and will be removed:"
$orphanedXRefDbs | ForEach-Object { Write-PSFMessage -Level Host -Message " - <c='em'>$_</c>" }
Write-PSFMessage -Level Important -Message "The following XRef databases are orphaned and will be removed:"
$orphanedXRefDbs | ForEach-Object { Write-PSFMessage -Level Important -Message " - <c='em'>$_</c>" }
}

$messageString = "This will remove all listed package directories and XRef DBs. If you are sure, please re-run the command with the <c='em'>-Force</c> parameter."

Write-PSFMessage -Level Host -Message $messageString -Target Host
Write-PSFMessage -Level Important -Message $messageString
Stop-PSFFunction -Message "Stopping because Force parameter wasn't supplied." -Exception $([System.Exception]::new($($messageString -replace '<[^>]+>', '')))
return
}
Expand Down Expand Up @@ -178,7 +178,7 @@ function Clear-UdeOrphanedConfig {
$sqlCommand.Connection.Close()
}
catch {
Write-PSFMessage -Level Host -Message "Something went wrong while working with the sql server connection objects or the database server threw an unexpected error." -Exception $PSItem.Exception
Write-PSFMessage -Level Important -Message "Something went wrong while working with the sql server connection objects or the database server threw an unexpected error." -Exception $PSItem.Exception
Stop-PSFFunction -Message "Stopping because of errors"
return
}
Expand Down
4 changes: 2 additions & 2 deletions d365bap.tools/functions/Compare-BapEnvironmentD365App.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function Compare-BapEnvironmentD365App {

if ($null -eq $envSourceObj) {
$messageString = "The supplied SourceEnvironmentId: <c='em'>$SourceEnvironmentId</c> didn't return any matching environment details. Please verify that the SourceEnvironmentId is correct - try running the <c='em'>Get-BapEnvironment</c> cmdlet."
Write-PSFMessage -Level Host -Message $messageString
Write-PSFMessage -Level Important -Message $messageString
Stop-PSFFunction -Message "Stopping because environment was NOT found based on the id." -Exception $([System.Exception]::new($($messageString -replace '<[^>]+>', '')))
}

Expand All @@ -102,7 +102,7 @@ function Compare-BapEnvironmentD365App {

if ($null -eq $envDestinationObj) {
$messageString = "The supplied DestinationEnvironmentId: <c='em'>$DestinationEnvironmentId</c> didn't return any matching environment details. Please verify that the DestinationEnvironmentId is correct - try running the <c='em'>Get-BapEnvironment</c> cmdlet."
Write-PSFMessage -Level Host -Message $messageString
Write-PSFMessage -Level Important -Message $messageString
Stop-PSFFunction -Message "Stopping because environment was NOT found based on the id." -Exception $([System.Exception]::new($($messageString -replace '<[^>]+>', '')))
}

Expand Down
4 changes: 2 additions & 2 deletions d365bap.tools/functions/Compare-BapEnvironmentUser.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ function Compare-BapEnvironmentUser {

if ($null -eq $envSourceObj) {
$messageString = "The supplied SourceEnvironmentId: <c='em'>$SourceEnvironmentId</c> didn't return any matching environment details. Please verify that the SourceEnvironmentId is correct - try running the <c='em'>Get-BapEnvironment</c> cmdlet."
Write-PSFMessage -Level Host -Message $messageString
Write-PSFMessage -Level Important -Message $messageString
Stop-PSFFunction -Message "Stopping because environment was NOT found based on the id." -Exception $([System.Exception]::new($($messageString -replace '<[^>]+>', '')))
}

Expand All @@ -111,7 +111,7 @@ function Compare-BapEnvironmentUser {

if ($null -eq $envDestinationObj) {
$messageString = "The supplied DestinationEnvironmentId: <c='em'>$DestinationEnvironmentId</c> didn't return any matching environment details. Please verify that the DestinationEnvironmentId is correct - try running the <c='em'>Get-BapEnvironment</c> cmdlet."
Write-PSFMessage -Level Host -Message $messageString
Write-PSFMessage -Level Important -Message $messageString
Stop-PSFFunction -Message "Stopping because environment was NOT found based on the id." -Exception $([System.Exception]::new($($messageString -replace '<[^>]+>', '')))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ function Compare-BapEnvironmentVirtualEntity {

if ($null -eq $envSourceObj) {
$messageString = "The supplied SourceEnvironmentId: <c='em'>$SourceEnvironmentId</c> didn't return any matching environment details. Please verify that the SourceEnvironmentId is correct - try running the <c='em'>Get-BapEnvironment</c> cmdlet."
Write-PSFMessage -Level Host -Message $messageString
Write-PSFMessage -Level Important -Message $messageString
Stop-PSFFunction -Message "Stopping because environment was NOT found based on the id." -Exception $([System.Exception]::new($($messageString -replace '<[^>]+>', '')))
}

Expand All @@ -89,7 +89,7 @@ function Compare-BapEnvironmentVirtualEntity {

if ($null -eq $envDestinationObj) {
$messageString = "The supplied DestinationEnvironmentId: <c='em'>$DestinationEnvironmentId</c> didn't return any matching environment details. Please verify that the DestinationEnvironmentId is correct - try running the <c='em'>Get-BapEnvironment</c> cmdlet."
Write-PSFMessage -Level Host -Message $messageString
Write-PSFMessage -Level Important -Message $messageString
Stop-PSFFunction -Message "Stopping because environment was NOT found based on the id." -Exception $([System.Exception]::new($($messageString -replace '<[^>]+>', '')))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function Confirm-BapEnvironmentIntegration {

if ($null -eq $envObj) {
$messageString = "The supplied EnvironmentId: <c='em'>$EnvironmentId</c> didn't return any matching environment details. Please verify that the EnvironmentId is correct - try running the <c='em'>Get-BapEnvironment</c> cmdlet."
Write-PSFMessage -Level Host -Message $messageString
Write-PSFMessage -Level Important -Message $messageString
Stop-PSFFunction -Message "Stopping because environment was NOT found based on the id." -Exception $([System.Exception]::new($($messageString -replace '<[^>]+>', '')))
}

Expand Down
14 changes: 7 additions & 7 deletions d365bap.tools/functions/Confirm-UdeVs2022Installation.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function Confirm-UdeVs2022Installation {

if ($null -eq $wmiObj) {
$messageString = "Visual Studio 2022 Professional or Enterprise does not appear to be installed on this machine. Please install Visual Studio 2022 Professional or Enterprise with the required workloads and try again."
Write-PSFMessage -Level Host -Message $messageString -Target Host
Write-PSFMessage -Level Important -Message $messageString
Stop-PSFFunction -Message "Stopping because Visual Studio 2022 was NOT installed." -Exception $([System.Exception]::new($($messageString -replace '<[^>]+>', '')))
return
}
Expand Down Expand Up @@ -94,9 +94,9 @@ function Confirm-UdeVs2022Installation {
process {
if (Test-PSFFunctionInterrupt) { return }

Write-PSFMessage -Level Host -Message "Starting the <c='em'>Visual Studio Installer</c>:" -Target Host
Write-PSFMessage -Level Host -Message " - You will need to click <c='em'>Modify</c> or <c='em'>Close</c> when prompted." -Target Host
Write-PSFMessage -Level Host -Message " - When the installation is finished, you will need to <c='em'>Close</c> the <c='em'>Visual Studio Installer</c> window." -Target Host
Write-PSFMessage -Level Important -Message "Starting the <c='em'>Visual Studio Installer</c>:"
Write-PSFMessage -Level Important -Message " - You will need to click <c='em'>Modify</c> or <c='em'>Close</c> when prompted."
Write-PSFMessage -Level Important -Message " - When the installation is finished, you will need to <c='em'>Close</c> the <c='em'>Visual Studio Installer</c> window."

# We need to make sure VS 2022 has the basic workloads installed
Start-Process -FilePath $pathVsInstaller `
Expand Down Expand Up @@ -129,17 +129,17 @@ function Confirm-UdeVs2022Installation {
continue
}

Write-PSFMessage -Level Host -Message "Extension: '<c='em'>$($ext.Name)</c>' is missing." -Target Host
Write-PSFMessage -Level Important -Message "Extension: '<c='em'>$($ext.Name)</c>' is missing."

Write-PSFMessage -Level Host -Message " - <c='em'>Downloading</c>..." -Target Host
Write-PSFMessage -Level Important -Message " - <c='em'>Downloading</c>..."

$file = (Split-Path -Path $ext.Uri -Leaf).Split('.') | Select-Object -Last 1
Invoke-WebRequest -Uri $ext.VsixUrl `
-OutFile "$Path\$file.vsix" `
-UseBasicParsing `
-ErrorAction Stop > $null

Write-PSFMessage -Level Host -Message " - <c='em'>Installing</c> - Please make sure to let the VSIX installer finish..." -Target Host
Write-PSFMessage -Level Important -Message " - <c='em'>Installing</c> - Please make sure to let the VSIX installer finish..."

Start-Process -FilePath "$Path\$file.vsix" `
-Wait
Expand Down
10 changes: 5 additions & 5 deletions d365bap.tools/functions/Export-BapEnvironmentSolution.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function Export-BapEnvironmentSolution {

if ($null -eq $envObj) {
$messageString = "The supplied EnvironmentId: <c='em'>$EnvironmentId</c> didn't return any matching environment details. Please verify that the EnvironmentId is correct - try running the <c='em'>Get-BapEnvironment</c> cmdlet."
Write-PSFMessage -Level Host -Message $messageString
Write-PSFMessage -Level Important -Message $messageString
Stop-PSFFunction -Message "Stopping because environment was NOT found based on the id." -Exception $([System.Exception]::new($($messageString -replace '<[^>]+>', '')))
}

Expand All @@ -59,7 +59,7 @@ function Export-BapEnvironmentSolution {

if ($null -eq $solObj) {
$messageString = "The supplied SolutionId: <c='em'>$SolutionId</c> didn't return any matching solution from the environment. Please verify that the SolutionId is correct - try running the <c='em'>Get-BapEnvironmentSolution</c> cmdlet."
Write-PSFMessage -Level Host -Message $messageString
Write-PSFMessage -Level Important -Message $messageString
Stop-PSFFunction -Message "Stopping because solution was NOT found based on the id." -Exception $([System.Exception]::new($($messageString -replace '<[^>]+>', '')))
}
}
Expand All @@ -69,7 +69,7 @@ function Export-BapEnvironmentSolution {

$tmp = pac org list --filter $EnvironmentId

Write-PSFMessage -Level Host -Message "<c='em'>$($tmp[0])</c>"
Write-PSFMessage -Level Important -Message "<c='em'>$($tmp[0])</c>"

$found = $false
foreach ($line in $tmp) {
Expand All @@ -82,7 +82,7 @@ function Export-BapEnvironmentSolution {

if (-not $found) {
$messageString = "It seems that the current pac cli session isn't connected to the correct tenant. Please run the <c='em'>pac auth create --name 'ChangeThis'</c> and make sure to use credentials that have enough privileges."
Write-PSFMessage -Level Host -Message $messageString
Write-PSFMessage -Level Important -Message $messageString
Stop-PSFFunction -Message "Stopping because pac cli session is NOT connected to the correct tenant." -Exception $([System.Exception]::new($($messageString -replace '<[^>]+>', '')))
}

Expand All @@ -95,7 +95,7 @@ function Export-BapEnvironmentSolution {

if (-not (($tmp | Select-Object -Last 1) -eq "Solution export succeeded.")) {
$messageString = "It seems that export of the solution encountered some kind of error. Please run the cmdlet <c='em'>again in a few minutes</c>."
Write-PSFMessage -Level Host -Message $messageString
Write-PSFMessage -Level Important -Message $messageString
Stop-PSFFunction -Message "Stopping because export failed." -Exception $([System.Exception]::new($($messageString -replace '<[^>]+>', '')))
}

Expand Down
Loading