Trying to create a simple backup script, but every time I run the script below, I receive the following error:
Copy-Item : Cannot overwrite the item C:\Users\Jacob\desktop\file1.txt with
itself.
At C:\Users\Jacob\desktop\test.ps1:5 char:1
+ Copy-Item $file $file.backup
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (C:\Users\Jacob\desktop\file1.txt:String) [Copy-Item], IOException
+ FullyQualifiedErrorId : CopyError,Microsoft.PowerShell.Commands.CopyItemCommand
Simple script:
Param(
[Parameter(Mandatory=$true)]
[string]$file
)
Copy-Item $file $file.backup
"$file has been backed up."