functions/get-d365sdpcleanup.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

<#
    .SYNOPSIS
        Get the cleanup retention period
         
    .DESCRIPTION
        Gets the configured retention period before updates are deleted
         
    .EXAMPLE
        PS C:\> Get-D365SDPCleanUp
         
        This will get the configured retention period from the registry
         
    .NOTES
        This cmdlet is based on the findings from Alex Kwitny (@AlexOnDAX)
         
        See his blog for more info:
        http://www.alexondax.com/2018/04/msdyn365fo-how-to-adjust-your.html
         
#>

function Get-D365SDPCleanUp {
    [CmdletBinding()]
    param (
        
    )
    
    $RegSplat = @{
        Path = "HKLM:\SOFTWARE\Microsoft\Dynamics\Deployment\"
        Name = "CutoffDaysForCleanup"
    }
    
    [PSCustomObject] @{
        CutoffDaysForCleanup = $( if (Test-RegistryValue @RegSplat) {Get-ItemPropertyValue @RegSplat} else {""} )
    }
}