I'm new to Powershell so this could be a simple error.
I'm using a SQL agent job to backup a database to a UNC path and then rename it.
The step type is 'Powershell"
The backup is done using Backup-SqlDatabase and works fine. It backups up directly to the UNC path
The rename is done as follows:
Rename-Item -Path "\\path\filename.txt" -NewName "test.bak"
I get the error "Invalid path '\\path\filename.txt'
I've used \\path\filename.txt in this post instead of the real path.
The path is valid and if I run the command from Powershell ISE it works fine.
Should it be possible to use rename-item, with a unc path, from a SQL Agent job? If so I'd appreciate any thoughts on what might be causing the error? I've checked permissions and it doesn't look to be that.