I have written a script that works as expected, however the log file is not populated and need to have the changes made create a log file, and keep appending the file anytime the scrip has run. Still pretty new to powershell so I dont completely understand piping yet. Can I get some help how I would actually show changes made please?
When I do a get help on rename-item, it indicates -passThru is not an accepted pipeline input, however -path and -newName are pipeline capable. I just dont know how I would display them if select-object does not work in this scenario.
Correct. That means it doesn’t accept “input” on the -PassThru parameter from the previous command in the pipeline (which is not what Passthru is designed for).
The -PassThru parameter exists on a number of commands that don’t normally produce output. Adding -PassThru makes them produce “output”. For example, Stop-Service doesn’t normally produce any output, but add the -PassThru parameter and it produces output as if you had run Get-Service after running Stop-Service.
What does -PassThru really accomplish? If a command doesn’t produce output, it has no results so there’s nothing to pipe to another command in the pipeline. By making it produce output (via the -PassThru parameter), it can then be piped to another command.