I am running a script in which has a path like below
and want to extract words display it like
as it goes through various paths and does the work. I have the code for the not deleted files and deleted files...
just would like to capture earlier mentioned details and display it while it is doing the function.
part of PowerShell function where I am using and capturing log using start-transcript - path "log path"
if ($files.count -gt 0)
{
Write-Host "List of Files not deleted"
for ($i= ($files.Count - $keep); $i -lt $Files.Length;
$i++)
{
#$Files[$i]
Write-output $files[$i].fullname
}
if (($files.Count - $keep) -gt 0)
{
# reduce the array to contain only the number of files in $keep
$files = $files | Sort-Object LastWriteTime | Select-Object -First $keep
Write-Output "------------------"
Write-Output "List of Deleted Files from "
Write-output "------------------"
Write-Output $files.FullName | format-table
Write-output "------------------"
#$date,"List of Files Deleted" $files.FullName | Add- Content -Path 'E:\backup\housekeep_log\Housekeep.log' #-verboes
#$files | Remove-Item -Force
}
stop-transcript
stored values in to a csv file...and called it through variable.
$config = Import-Csv -Path 'E:\Backup\Scripts\HousekeepConfig.csv'
#Write-Output $Config
$date = Get-Date -Format "yyyMMdd_hhmmss"
Start-Transcript -Path E:\Backup\Housekeep_Log\Housekeep.log
$oldpath = get-location
foreach ($item in $config)
{
Write-host $item.Name | Format-table