Skip to content
This repository was archived by the owner on May 28, 2021. It is now read-only.

Commit 5335241

Browse files
committed
Add -log parameter for transcript output, reimplements #207
1 parent 1070655 commit 5335241

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,11 @@ The script supports command line options and parameters which can help you custo
8888

8989
## Advanced usage
9090

91-
powershell.exe -NoProfile -ExecutionPolicy Bypass -File Win10.ps1 [-include filename] [-preset filename] [[!]tweakname]
91+
powershell.exe -NoProfile -ExecutionPolicy Bypass -File Win10.ps1 [-include filename] [-preset filename] [-log logname] [[!]tweakname]
9292

9393
-include filename load module with user-defined tweaks
9494
-preset filename load preset with tweak names to apply
95+
-log logname save script output to a file
9596
tweakname apply tweak with this particular name
9697
!tweakname remove tweak with this particular name from selection
9798

@@ -157,6 +158,14 @@ Command using all three examples combined:
157158

158159
 
159160

161+
### Logging
162+
163+
If you'd like to store output from the script execution, you can do so using `-log` parameter followed by a filename of the log file you want to create. For example:
164+
165+
powershell.exe -NoProfile -ExecutionPolicy Bypass -File Win10.ps1 -include Win10.psm1 -preset mypreset.txt -log myoutput.log
166+
167+
The logging is done using PowerShell `Start-Transcript` cmdlet, which writes extra information about current environment (date, machine and user name, command used for execution etc.) to the beginning of the file and logs both standard output and standard error streams.
168+
160169
## Maintaining own forks
161170

162171
The easiest way to customize the script settings it is to create your own preset and, if needed, your own tweak scripts as described above. For easy start, you can base the modifications on the *Default.cmd* and *Default.preset* and maintain just that. If you choose to fork the script anyway, you don't need to comment or remove the actual functions in *Win10.psm1*, because if they are not called, they are not used.

Win10.ps1

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ While ($i -lt $args.Length) {
4141
$PSCommandArgs += "-preset `"$preset`""
4242
# Load tweak names from the preset file
4343
Get-Content $preset -ErrorAction Stop | ForEach-Object { AddOrRemoveTweak($_.Split("#")[0].Trim()) }
44+
} ElseIf ($args[$i].ToLower() -eq "-log") {
45+
# Resolve full path to the output file
46+
$log = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($args[++$i])
47+
$PSCommandArgs += "-log `"$log`""
48+
# Record session to the output file
49+
Start-Transcript $log
4450
} Else {
4551
$PSCommandArgs += $args[$i]
4652
# Load tweak names from command line

0 commit comments

Comments
 (0)