- 1 year ago
PS script to copy data to external file share location
Here's an example PowerShell script that demonstrates how to copy data to an external file share location:
powershell$sourcePath = "C:\Path\to\source\folder"
$destinationPath = "\\server\share\destination\folder"
# Copy the files and subdirectories from the source to the destination
Copy-Item -Path $sourcePath -Destination $destinationPath -Recurse
In the script above, you need to specify the $sourcePath
variable with the path to the source folder or file that you want to copy. Update the $destinationPath
variable with the network path to the destination file share where you want to copy the data.
The Copy-Item
cmdlet is used to perform the actual file copy operation. The -Path
parameter specifies the source path, and the -Destination
parameter specifies the destination path. The -Recurse
switch is added to ensure that both files and subdirectories are copied.
You can save the script with a .ps1 extension (e.g., CopyData.ps1
), and then run it using PowerShell. Make sure you have the necessary permissions to access the source and destination locations.