I was trying to build our own custom token to update our customized unattend files for server builds. We have multiple domains where servers are built but wanted sysprep to handle joining the computer to the domain. I figured I could create our own JOIN Token similar to how the deployment task does it. However the are some major flaws to how DS7 tokens work that caused many headaches.
- First you can't use LIKE in a CASE statement or anyplace else as the % character automatically makes the token tool think anything between % and the next % will be another token. For instance: CASE WHEN FQDN LIKE '%.DomainA.COM' Then 'DomainA' WHEN FQDN LIKE '%.DomainB.COM' Then 'DomainB'. In this case the Token function will think this is a token to replace: ''%.DomainA.COM' Then 'DomainA' WHEN FQDN LIKE '%' and fail.
- Next is the use of + and !. If these exist the token will first save but then strip out these characters causing errors in scripts or strings that might use them.
- A huge PITA factor is that the token SQL has to be all on the same line. This is fine if it's a simple query however, more advance queries become very hard to manage as you can't just copy a cleanly formatted SQL query in as a token.
- Finally once you can get everything working output will replace < and > characters with < and > So '<Identification>' will end up looking like <Identification>. Defeating the hole endeavor.