Forum Discussion
Mike Jansen
Jul 03, 2017Iron Contributor
Powershell > Output to .txt as one string
I have a powershell script that loops a fileshare and reports the properties of all the files. This part reports to a .txt file: Get-ChildItem -Recurse $source | ?{-not $_.PSIsContainer} | ForEach...
- Jul 03, 2017
Try this script for output with txt file
$Details=Get-ChildItem -Recurse $source | ?{-not $_.PSIsContainer} | ForEach-Object {Audit-File $_} | Sort-Object fullname | Select FullName,CreationTime,LastWriteTime,Length,Owner $Outputs =@() ForEach($Detail in $Details) { $Output = "Fullname,"+$Detail.FullName+",CreationTime,"+$Detail.CreationTime+",LastWriteTime ,"+ $Detail.LastWriteTime+",Length ,"+"$Detail.Length"+ ",Owner,"+$Detail.Owner $Outputs +=$Output } $Outputs | Out-File C:\filename.txt
Manidurai Mohanamariappan
Jul 03, 2017Iron Contributor
Try this script for output with txt file
$Details=Get-ChildItem -Recurse $source | ?{-not $_.PSIsContainer} | ForEach-Object {Audit-File $_} | Sort-Object fullname | Select FullName,CreationTime,LastWriteTime,Length,Owner $Outputs =@() ForEach($Detail in $Details) { $Output = "Fullname,"+$Detail.FullName+",CreationTime,"+$Detail.CreationTime+",LastWriteTime ,"+ $Detail.LastWriteTime+",Length ,"+"$Detail.Length"+ ",Owner,"+$Detail.Owner $Outputs +=$Output } $Outputs | Out-File C:\filename.txt