When you run Start-Transcript, PowerShell will document all console input and output in a file. To remove all output and create a file with your PowerShell commands only, you should use this piece of code:
$path = "$home\Documents\allcommands.txt"
dir $home\Documents\*transc* |
ForEach-Object { Get-Content $_.FullName } |
ForEach-Object { if ($_ -match '^PS.*?>') {
$_.SubString($matches[0].Length).Trim()
}
} |
Where-Object { $_ } |
Out-File $path
Invoke-Item $path