Author | Chrissy LeMaire (@cl), netnerds.net |
Availability | Windows, Linux, macOS |
Want to see the source code for this command? Check out Invoke-DbatoolsRenameHelper on GitHub.
Want to see the Bill Of Health for this command? Check out Invoke-DbatoolsRenameHelper.
Updates PowerShell scripts to replace deprecated dbatools command and parameter names with current equivalents.
Automatically scans and updates PowerShell script files to replace old dbatools command names and parameter names that have been renamed over time. This function searches through your scripts for over 200 deprecated command names and dozens of parameter renames, then updates the file content with the current naming conventions. Instead of manually hunting through scripts to update commands like Get-SqlMaxMemory to Get-DbaMaxMemory or Copy-SqlLogin to Copy-DbaLogin, this function handles the bulk replacement work for you.
Invoke-DbatoolsRenameHelper
[-InputObject] <FileInfo[]>
[[-Encoding] <String>]
[-EnableException]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
PS C:\> Get-ChildItem C:\temp\ps\*.ps1 -Recurse | Invoke-DbatoolsRenameHelper
Checks to see if any ps1 file in C:\temp\ps matches an old command name.
If so, then the command name within the text is updated and the resulting changes are written to disk in UTF-8.
PS C:\> Get-ChildItem C:\temp\ps\*.ps1 -Recurse | Invoke-DbatoolsRenameHelper -Encoding Ascii -WhatIf
Shows what would happen if the command would run. If the command would run and there were matches,
the resulting changes would be written to disk as Ascii encoded.
Specifies the PowerShell script files to scan and update for deprecated dbatools command and parameter names.
Accept file objects from Get-ChildItem when you need to process multiple scripts containing outdated dbatools commands.
Use this when modernizing existing automation scripts or migrating legacy PowerShell code to current dbatools naming conventions.
Alias | |
Required | True |
Pipeline | true (ByValue) |
Default Value |
Sets the character encoding used when writing the updated script files back to disk. Defaults to UTF8.
Use this when your PowerShell scripts require specific encoding formats for compatibility with source control systems or deployment processes.
Most modern environments work well with the default UTF8 encoding, but legacy systems may require ASCII or other specific encodings.
Alias | |
Required | False |
Pipeline | false |
Default Value | UTF8 |
Accepted Values | ASCII,BigEndianUnicode,Byte,String,Unicode,UTF7,UTF8,Unknown |
By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.
This avoids overwhelming you with "sea of red" exceptions, but is inconvenient because it basically disables advanced scripting.
Using this switch turns this "nice by default" feature off and enables you to catch exceptions with your own try/catch.
Alias | |
Required | False |
Pipeline | false |
Default Value | False |
Shows what would happen if the command were to run. No actions are actually performed
Alias | wi |
Required | False |
Pipeline | false |
Default Value |
Prompts you for confirmation before executing any changing operations within the command
Alias | cf |
Required | False |
Pipeline | false |
Default Value |