By: Tim Smith | Updated: 2014-06-12 | Comments (1) | Related: > PowerShell
Problem / Solution
A task that often needs to be performed by SQL Server DBAs and Developers is the need to move and rename files that are sitting on the file system. This may be database backup files that are moved to an archive folder along with renaming the file to include a date timestamp or maybe import or export files that are created using SSIS or T-SQL code. There are several different ways this can be done such as using xp_cmdshell or a batch file, but in this video tip Tim Smith shows how this can be done using PowerShell. He will also show how you can create a function that can be used over and over again by just passing in a few parameters, so that the code is reusable for any process that needs to rename and move a file.
Key Learning Items
- Using PowerShell variables
- PowerShell cmdlet Rename-Item
- PowerShell cmdlet Move-Item
- PowerShell cmdlet Get-Date
- Creating a PowerShell function
Read Companion Tip
About the author
This author pledges the content of this article is based on professional experience and not AI generated.
View all my tips
Article Last Updated: 2014-06-12