I'm running powershell script with batch file.
My requirement is:-
- display the output in batch cmd and at the same time save output in TXT file. Note, as of now output getting saved in txt file but output is not visible in batch cmd.
- Create a folder with system serial number in C drive and save txt file in that folder.
Batch File name:- Check.bat
Powershell script name:- Check.ps1 (powershell file contains bulk commands which output will be displayed in batch file as a command prompt)
Batch file code:-
@echo off
for /F %%a in ('wmic bios get serialnumber') do call :Sub %%a
:Sub
if not "%*"=="" set SerialNumber=%*
xcopy "%~dp0*" "C:\windows\Temp\Compliance_Check" /q /s /e /y /i
PowerShell.exe -ExecutionPolicy Bypass -File %~dp0Compliance_Check.ps1 > C:\%SerialNumber%\output.txt
pause
$command = .\program.exe; write-host $command; $command | out-file -append "log.txt"