Forum Discussion
Expand-DedupFile - expand files on other Servers?
It doesn't seem to work on UNC paths and mapped drives, I changed the script a little bit and used invoke-command to start the command locally on the remote server using the $folder_location to which PowerShell changes it's current directory and recursively deduplicates the files. It does work (Checked using the Measure-DedupFileMetadata cmdlet), but still throws errors like parameter incorrect 🙂
# Prompt user for file path
$folder_location = Read-Host -Prompt 'Enter the local path to the files to expand, e.g. e:\data'
# Prompt for server name
$server = Read-Host -Prompt 'Enter server name'
# Run remote command on remote server using foldername
Invoke-Command -ComputerName $server -ScriptBlock {
Push-Location $using:folder_location
Get-ChildItem -Recurse | Expand-DedupFile
}
- Jan 29, 2022Does this work for you like this?
- user4444Feb 02, 2022Copper ContributorHello,
apologies for the delayed response.
This script doesn't work, but I think it might be more to do with the paths to folders.
Perhaps if I explain the bigger picture it might help.
You were kind enough to help me with a script on another thread where I was searching for folders in various network locations. I suppose we could call that part 1 of the process.
After finding the folders I need to expand the files inside them.
I would like my colleague who uses these scripts to be able to run them from one location (not locally). To do that the paths to search will be network shares rather than local folders.
So, while the script to search for the folders in network shares works, it returns the locations as network paths, not local. The script you have provided here requires local paths. I did some testing using local paths but this didn't work, however, it's quite likely due to me making a mistake.- Feb 02, 2022
Strange, I tested it using invoke-command with a local path and it did return a error code but the Measure-DedupFileMetadata statistics showed me that the files were not dedupped anymore...
So, if you enter e:\data and servername server01.. It connects to server01 using a invoke-command and does a expand-dedupfile command on e:\data.Could take some time to dedup the files, but run a measure-dedupfilemetadata before and after running the script on the target server to check the diffence.