Jul 27 2022 04:36 AM
Hi,
Trying to run SFC scan every day using task scheduler ,however the result are storing in default location C:\Windows\Logs\CBS CBS text file ,
Written Batch file ,to run sfc scan and save the output in user desktop or local disk C
--------- Below 2 lines copied and saved as .bat -------
sfc /scannow
findstr /c:"[SR]" %windir%\Logs\CBS\CBS.log > C:\sfclogs.txt
however it was failed to run.
+++++++++++++++++++++++++++++++++
have PowerShell script but i don't know where to place sfc /scannow command in the script
Get-Content -Path "$env:windir\Logs\CBS\CBS.log" |
Where-Object { $input -like "*[SR]*" } |
Out-File -FilePath "$env:USERPROFILE\Desktop\sfcdetails.txt"
+++++++++++++++++++++++++++++++++++++
Could you please suggest me here.
Jul 27 2022 05:03 AM - edited Jul 27 2022 05:06 AM
On the top of Get-Content
Sfc /scannow
Get-Content -Path "$env:windir\Logs\CBS\CBS.log" |Where-Object { $input -like "*[SR]*" } |Out-File -FilePath "$env:USERPROFILE\Desktop\sfcdetails.txt"
---------------
If this answer help, Please click on Best Response and hit the like 🙂
Jul 27 2022 06:03 AM
Jul 27 2022 07:46 AM
Yes
sure you can use the following as a FilePath
-FilePath "$env:USERPROFILE\Desktop\$(get-date -Format "DD-MM-yyyy").txt"
Jul 27 2022 10:31 AM
@farismalaeb : The output name is still not coming with date,month,year with time its not coming .
please screenshot .
It should come like sfc_report_date.month.year.timestamp
could you please assist me
Jul 27 2022 10:05 PM
Jul 27 2022 11:35 PM
Thank you !
now it's working fine.
One request i tried to print hours & mints also like below
$(get-date -Format "ddMMyyyy HH:mm:ss").txt"
but it is getting error , could you let me know how can i get output file with date month year hours and mints and seconds as well ,
it is possible to get the file like --> sfc_scanreport_28-07-2022-hours-mints-seconds
like that so that we can easily identify the file name .
Jul 27 2022 11:59 PM
SolutionJul 27 2022 11:59 PM
Solution