I have two scripts Register-DnsRecord.ps1 and Unregister-DnsRecord.ps1. Any time I add or remove a script through the GUI the Register-DnsRecord.ps1 script is renamed to Unregister-DnsRecord.ps1 and the description is updated to match the Unregister-DnsRecord.ps1 script.
This ends up with two scripts with different paths both having the same name and description.
If I rename the script and fix the description in the GUI it leaves the OLD Unregister-DnsName.ps1 entry in scripts.ps1 and creates a new correct Register-DnsName.ps1 entry. I have to manually clean up the scripts.ps1 to fix the issue.
This doesn't happen with another similarly named set of scripts Unregister-NetworkDnsName.ps1 and Register-NetworkDnsName.ps1
I removed and recreated both scripts with their original names and content and the issue seems to have resolved.
Hello,
Thank you for the detailed report on the forum.
I am glad that removing and recreating both scripts cleared the problem for now.
I would still like to reproduce it on our side so it can be fixed for good.
From what I can see, PowerShell Universal rewrites the whole scripts.ps1 file each time a script is added or removed in the admin console.
That means the wrong name and description were already stored on the Register-DnsRecord.ps1 entry before the file was written.
To find out how that entry got mixed up, could you share the following?
If your repository is in Git, the scripts.ps1 history from before your manual cleanup, ideally the first commit where the Register-DnsRecord.ps1 entry shows the wrong name.
The top of both script files, in particular any [DisplayName()] attribute or comment-based help block.
How Register-DnsRecord.ps1 was first created: with New Script in the admin console, by copying Unregister-DnsRecord.ps1 on disk, or another way.
Whether both scripts sit in the same folder, and whether a Script Base Folder is set.
Your hosting type (Windows service, IIS or Docker) and your database (SQLite or SQL Server).
If the problem comes back, please save a copy of scripts.ps1 before you fix it.
That copy shows us the bad state directly.
Until then, keeping scripts.ps1 in Git, or taking a quick backup before you add or remove scripts, makes recovery much easier.
Here is how script names and comment-based help are handled in PowerShell Universal: https://docs.devolutions.net/powershell-universal/automation/scripts
Best regards,
Patrick Ouimet