Custom script samples
- Last Updated: January 27, 2026
- 1 minute read
- Automate MFT
- Documentation
These samples show practical ways to use custom scripts in Automate MFT tasks.
Sample scripts
Add a new file to the
cache
$newItem = Add-MftItem -Name 'mine.txt'
Set-MftContent -Item $newItem -Value 'this is the new item content'Remove files that are named ‘1.txt’ and change the content of the
others
$items = Get-MftItem
foreach ($item in $items) {
if ($item.Name -eq ""1.txt"") {
Remove-MftItem -Item $item
}else {
Set-MftContent -Item $item -Value 'brand new content'
}
}Rename files and change the output directory to
new-output
$items = Get-MftItem
foreach ($item in $items) {
Rename-MftItem -Item $item -NewName "new-output/$($item.Name)-renamed"
}