How do I display the changes made on this script?

Viewed 33

How can I make it so that it can display see the changes this script made? it should look like '"folder name' changed in the 'path'" The path is where the folder name is located.

Get-ChildItem -Path ‘C:\SCRIPT TEST ’ –Recurse| 
Foreach-Object { Rename-Item $_.FullName ($_.FullName -replace "hello","goodbye")}

Thanks so much!

1 Answers

If you want to test beforehand, use -whatif

Get-ChildItem -Path ‘C:\SCRIPT TEST ’ –Recurse| 
Foreach-Object { Rename-Item $_.FullName ($_.FullName -replace "hello","goodbye") -whatif}

If you want detailed output, use -verbose

Get-ChildItem -Path ‘C:\SCRIPT TEST ’ –Recurse| 
Foreach-Object { Rename-Item $_.FullName ($_.FullName -replace "hello","goodbye") -verbose}

It's recommended to support these when writing your own scripts in future also.

Related