[25] Windows Power Shell DSC Learning Series - How to replace DSC Pull server database as Access database?

Keywords: Database SQL Windows

As we know, the default database of PowerShell DSC is ESENT file database, or Access database in oleDB form (database file suffix: mdb).

Under the default installation mode, if the Pull server is installed with xDscWebService DSC resources, the default mode is ESENT file database; how to change the storage database of the Pull server into Access database? The answer is really simple, just modify the MSFT_xDSCWebService.psm1 file.




The specific steps and methods are as follows:

First, find the file MSFT_xDSC WebService.psm1 in the installation directory of the Pull server. For example, the author's current environment is PowerShell DSC 5.1; the file directory of its xPS Desired State Configuration DSC module is in C: Program Files\ Windows PowerShell Modules\ xPSDestedConfiguration\ 5.1.0\ DSesoCR MSFT WebDSC Service.

Find the MSFT_xDSCWebService.psm1 file and open it with PowerShell ISE.


Then, in the function Set-Target Resource method, find the place where the variable $isDownlevelOfBlue, $IsBlue is assigned, and insert the following code.

 

The script for installing the Pull service remains unchanged, as follows:

#New-SelfSignedCertificate -certstorelocation cert:\localmachine\my -dnsname sql-pull-server.example.com
configuration InstallxDsc5PullServer
{ 
    param  
    ( 
            [string[]]$NodeName = 'localhost', 


            [ValidateNotNullOrEmpty()] 
            [string] $certificateThumbPrint,


            [Parameter(Mandatory)]
            [ValidateNotNullOrEmpty()]
            [string] $RegistrationKey 
     ) 


     Import-DSCResource -ModuleName xPSDesiredStateConfiguration
     Import-DSCResource –ModuleName PSDesiredStateConfiguration


     Node $NodeName 
     { 
         WindowsFeature DSCServiceFeature 
         { 
             Ensure = 'Present'
             Name   = 'DSC-Service'             
         } 


         xDscWebService PSDSCPullServer 
         { 
             Ensure                   = 'Present' 
             EndpointName             = 'PSDSCPullServer' 
             Port                     = 8080 
             PhysicalPath             = "$env:SystemDrive\inetpub\PSDSCPullServer" 
             CertificateThumbPrint    = $certificateThumbPrint          
             ModulePath               = "$env:PROGRAMFILES\WindowsPowerShell\DscService\Modules" 
             ConfigurationPath        = "$env:PROGRAMFILES\WindowsPowerShell\DscService\Configuration" 
             State                    = 'Started'
             DependsOn                = '[WindowsFeature]DSCServiceFeature'     
             UseSecurityBestPractices = $false
         } 


        File RegistrationKeyFile
        {
            Ensure          = 'Present'
            Type            = 'File'
            DestinationPath = "$env:ProgramFiles\WindowsPowerShell\DscService\RegistrationKeys.txt"
            Contents        = $RegistrationKey
        }
    }
}


InstallxDsc5PullServer  -certificateThumbprint 'DEBD244CA738E89177E00685B53BD1C02BB9EB72' -RegistrationKey '589303f2-482e-478e-97cb-b1a278f07458' -OutputPath c:\DSC\PullServer
Start-DscConfiguration -Force -Path c:\DSC\PullServer -Wait -Verbose 

After executing the above script, we went to the installation directory of Access database, C: Program Files Windows PowerShell DscService, and found that the data of its Pull server had been replaced by Access database.



Opening the data, we can see that there are three tables: Devices,Registration and StatusReport. It seems that the implementation of Pull server is quite simple.




In this chapter, I share how to replace the Pull server's database as Access for the latter chapter; because whether it's an ESEIN file database or Acces data, its performance, manageability and the capacity of its database are very limited. But the official DSC does not support MS SQL Server by default, so is there any good way to support MS SQL Server? Please look forward to the next article.




Posted by rrhody on Tue, 18 Dec 2018 01:54:04 -0800