Examples/xTokenize_NoTokenFile.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 |
############################################################ # DSC Tokenization Example - No Token File # # This script supports using the technique described in this # blog post http://tinyurl.com/tokenization which uses the # XML transform functionality of Web Deploy to create a # tokenized version of the web.config. This technique does # not require a .token file to be in the target folder. # # Running this example will create a new subfolder in the # examples folder where the transformation of the files will # take place. # Define configuration data to be used in the configuration. # This is normally done in a separate file but included here # for this example. $ConfigData = @{ AllNodes = @( @{ NodeName = "localhost"; SourcePath = "$($PSScriptRoot)\noTokenfile_drop\"; DestinationPath = "$($PSScriptRoot)\noTokenfile_target\"; Tokens = @{Database="db01"}; SearchPattern = "*.config" } ) } Configuration TokenizeFiles { # You have to import the xReleaseManagement resource before # you can use it in your configuration Import-DscResource -ModuleName xReleaseManagement # Node is read from ConfigData defined above Node $AllNodes.NodeName { # Use the built in File resource to copy files File CopyBits { Ensure = "Present" Force = $true Recurse = $true Type = "Directory" SourcePath = $Node.SourcePath DestinationPath = $Node.DestinationPath } # Use the xTokenize resource to transform your web.config files xTokenize WebConfigs { dependsOn = "[File]CopyBits" recurse = $true tokens = $Node.Tokens useTokenFiles = $false path = $Node.DestinationPath searchPattern = $Node.SearchPattern } } } TokenizeFiles -ConfigurationData $ConfigData Start-DscConfiguration -Wait -Verbose -Path .\TokenizeFiles -Force |