Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update tiny11maker.ps1 (Param fix, unique log file with date) #261

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 24 additions & 11 deletions tiny11maker.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Enable debugging
#Set-PSDebug -Trace 1
# Enable debugging (uncomment if needed)
# Set-PSDebug -Trace 1

# Define script parameters at the top
param (
[string]$ScratchDisk
)
# Seting the release date/version
$releaseDate = "05-06-24"

# If ScratchDisk is not provided, use the system drive
if ($Null -eq $ScratchDisk) {
$ScratchDisk = $env:SystemDrive
}

# Check if PowerShell execution is restricted
if ((Get-ExecutionPolicy) -eq 'Restricted') {
Expand All @@ -19,8 +31,7 @@ $adminGroup = $adminSID.Translate([System.Security.Principal.NTAccount])
$myWindowsID=[System.Security.Principal.WindowsIdentity]::GetCurrent()
$myWindowsPrincipal=new-object System.Security.Principal.WindowsPrincipal($myWindowsID)
$adminRole=[System.Security.Principal.WindowsBuiltInRole]::Administrator
if (! $myWindowsPrincipal.IsInRole($adminRole))
{
if (! $myWindowsPrincipal.IsInRole($adminRole)) {
Write-Host "Restarting Tiny11 image creator as admin in a new window, you can close this one."
$newProcess = new-object System.Diagnostics.ProcessStartInfo "PowerShell";
$newProcess.Arguments = $myInvocation.MyCommand.Definition;
Expand All @@ -29,17 +40,19 @@ if (! $myWindowsPrincipal.IsInRole($adminRole))
exit
}

param ($ScratchDisk)
if ($Null -eq $ScratchDisk) {
$ScratchDisk = $env:SystemDrive
}

# Start the transcript and prepare the window
Start-Transcript -Path "$PSScriptRoot\tiny11.log"

# Generate a unique log file name with the date and time
$timestamp = Get-Date -Format "yyyyMMdd_HHmmss"
$logFile = "$PSScriptRoot\tiny11_$timestamp.log"

# Start transcript
Start-Transcript -Path "$logFile" > $null 2>&1

$Host.UI.RawUI.WindowTitle = "Tiny11 image creator"

Clear-Host
Write-Host "Welcome to the tiny11 image creator! Release: 05-06-24"
Write-Host "Welcome to the tiny11 image creator! Release: $releaseDate"

$hostArchitecture = $Env:PROCESSOR_ARCHITECTURE
New-Item -ItemType Directory -Force -Path "$ScratchDisk\tiny11\sources" >null
Expand Down