Use one license.xml for all local Sitecore instances with SymbolicLink
It's common for us who work with Sitecore having multiple Sitecore instances locally.
When the time comes that the license.xml expires and needs to be replaced, it's a bit of manual work to replace all the locations. There are PowerShell scripts to replace all at once but I wanted it to be even easier, so tried pointing all license.xml to one license.xml file using symlink which is supported by Windows.
Saving below scripts into a PowerShell(ps1) file and executing should replace all license.xml files under c:\inetpub\wwwroot to link to the license.xml defined in the scripts. You can change the 2 parameters as well if required.
Param(
[string] $licenseFile = "C:\ResourceFiles\license.xml",
[string] $websitesRoot = "C:\inetpub\wwwroot"
)
function make-link ($target, $link) {
New-Item -Path $link -ItemType SymbolicLink -Value $target
}
Set-Location $websitesRoot
Get-ChildItem -Filter license.xml -Recurse | Select FullName | ForEach-Object {
#Write-Host "Processing "$_.FullName
Rename-Item -Path $_.FullName -NewName "license.xml.bak"
#Write-Host "Rename to license.xml.bak"
make-link -target $licenseFile -link $_.FullName
#Write-Host "Link created"
}
Also make sure to run the script as an administrator and make sure the target license.xml is readable by all IIS apps.