Share via


Profile Script From my Workshop VMs

I had a student today ask for a copy of the profile I showed during class where I set error background color and start a transcript.  Here is the code:

 $option1 = New-Object System.Management.Automation.Host.ChoiceDescription("&Yes","You chose yes...")            
$option2 = New-Object System.Management.Automation.Host.ChoiceDescription("&No","You chose no...")            
$choices = [System.Management.Automation.Host.ChoiceDescription[]]($option1, $option2)            
$chosen = $host.ui.PromptForChoice("Error Background","Do you want error background to be white?",$choices,1)            
            
If ($chosen -eq 0) {$Host.PrivateData.ErrorBackgroundColor = "white"}            
            
$LessonNumber = Read-Host "Enter Lesson Number"            
$now = Get-Date -Format 'dddd-hhmmtt'            
Start-Transcript "C:\transcripts\PowerShell-Class-Lesson-$LessonNumber-Transcript-$now.txt"            
#Start-Transcript ("C:\transcripts\PowerShell-Class-Lesson-$LessonNumber-Transcript-{0:dddd-hhmmtt}.txt" -f (Get-Date))