1

I would like some assistance getting a powershell script to work correctly. A piece of it is pasted below. Basically what I'm trying to do is to move all files in various subdirectories to another location. I can get the files to move and the folders to create fine, I'm just having a problem with getting the results to a text file. I've tried using out-file, but the txt file is empty. I've also tried start-transcript, but notepad doesn't seem to see line breaks and all the text bleeds together. Is there a better way to go about this? I'm using this basic command for testing.

Start-Transcript c:\log.txt
Move-Item c:\temp\*.* C:\Temp\2014 -Verbose -Force
Stop-Transcript

1 Answer 1

1

You may just need to collapse the output file descriptors. According to the about_Redirection page, it should work if you do the following:

Move-Item c:\temp\*.* C:\Temp\2014 -Verbose -Force *>&1 | 
    Out-File -FilePath $MyLogPath

Or if you want to see the output at the same time

Move-Item c:\temp\*.* C:\Temp\2014 -Verbose -Force *>&1 |
    Tee-File -FilePath $MyLogPath
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.