Open FH-Inway opened 2 years ago
Have to do some more testing, but no matter the outcome, I think the cmdlet should be modified to not execute the rest if Rename-Computer
fails.
Try to use -EnableException parameter to stop the execution of the script
When running [Rename-D365ComputerName]() with an invalid
-NewName
parameter (e.g.d365fo.tools
), the rename fails with an error message saying "Rename-Computer : Skip computer 'MININT-57EHFHJ' with new name 'd365fo.tools' because the new name is not valid.". Despite this, the the rest of the cmdlet is executed.Another run of the cmdlet with a valid name renames the computer correctly, but now execution of the rest of the cmdlet causes issues: "Something went wrong while working against the database. | Exception calling "ExecuteNonQuery" with "0" argument(s): "The server 'MININT-57EHFHJ' does not exist. Use sp_helpserver to show available servers. The server 'd365fo-tools' already exists.""
Not sure yet if this breaks the environment.
Gist with full PowerShell session