Automatic Configured Problem Step Recorder (PSR)


 

Everyone that knows me will tell you that I advocate two tools more than any other. Matter of fact, some will say that I nag them about PSR the most; “Where is your PSR”, “How come you haven’t started your PSR”. I always try to remember to start the Problem Step Recorder when I log into a system which I am planning to perform troubleshooting, make a change, or even to document something.

 

One of the BIGGEST problems with the Problem Step Recorder is once you launch the application you have to configure the settings. Where to save the file and how many screen shots do you want , if you don’t do this, you’ll only get the 25 screen shots, and if you click more than 25 times, you loose the oldest screen shots for each click of the mouse. I created a script that will perform the following task each time it is launched:

 

  • Specify the output file and path of the psr.exe recorded session, the default value is C:\Temp\PSR_(2-digit month).(2-digit day).(4-digit year).Hour-Minute(AM/PM).zip.
  • Specify the maximum number of screen captures psr.exe will capture. Valid values are 1-999. Note that Windows 7, 2008 and earlier versions only allow the max value of 100.

 

Notes:

  • You may need to change your “ExecutionPolicy” so that these scripts will run.
  • If you want a different path to save the screen captures, you need to update the paths in the “InvokePSR.psm1” and “PSR.ps1”.

 


I placed the “PSR.ps1” file on my desktop; when executed to run the following may occur the first time, but after that it should start the Problem Step Recorder automatically.

 

First the script is going to verify if the directory where the recording will be save does exists. If it does not it will ask if you want it to be created.

image

 

Next the script is going to detect the operating system and it will configure the screen capture value to the maximum setting allowed.

You may or may not see the following, if you do, then this information is only stating what the screen capture is set to and where the recording will be located when it is stopped.

image

 

You will need to stop the PSR manually, so that it will be save into the specified directory provided inside the “InvokePSR.psm1”.

Note: I recommend that you close the Problem Step Recorder, and re-run the “PSR.ps1” script again so that you will get a new file name automatically and not over write the one you just created.

 

image

 

Simple as that.

 


 

One of the things that I have configured in my lab is for the PSR to automatically launch when I log on to a system. The reasoning behind this, so that the PSR automatically start when I logs into a lab server, it is ready to capturing screenshots. Sometime I simply forget to start the PSR when I am working on something in which I needed to be captured. There is nothing like trying to remember what you did, what happen, or I needed it to be documented only to end up back at step one.

 

Open up the Task Scheduler and create a new task. On the “General” tab provide a name, you can name it whatever you like.

 

On the “Triggers” tab, create a task to execute “At log on”.

image

 

On the “Action” input the following:

 

Action: Start a program

Program/script: PowerShell.exe

Arguments: -Command "Import-Module C:\Invoke-PSR\InvokePSR.psm1";" Invoke-PSR -Start -RunAsAdministrator"

 

image

 

Hit the “Ok” button when done. and the next time you log in it will fire off the Problem Step Recorder.

 

KEEP IN MIND that these files take up space and will fill up a drive over time, so you need to clean them out when no longer needed.

 

If you would like a copy of these script you can find it here

 

Here is what the scripts look like inside

PSR.ps1:


Import-Module "C:\Invoke-PSR\InvokePSR.psm1"
Invoke-PSR -Start -RunAsAdministrator


InvokePSR.psm1:


Function Invoke-PSR
{
<#

.SYNOPSIS
Starts psr.exe

 .DESCRIPTION
Starts psr.exe with specified parameters
 .PARAMETER Output
Specify the output file and path of the psr.exe recorded session, the default value is C:\Temp\PSR_(2-digit month).(2-digit day).(4-digit year).Hour-Minute(AM/PM).zip
 .PARAMETER MaxScreenCapture
Specify the maximum number of screen captures psr.exe will capture. Valid values are 1-999. Note that Windows 7 and earlier versions the max value is 100
 .PARAMETER Start
Specify if you want to start psr.exe with the recording started
 .PARAMETER RunAsAdministrator
Specify that you want to start psr.exe with elevated permissions
 .EXAMPLE
Invoke-PSR -Start -RunAsAdministrator
 This will start and elevated psr.exe with the recording started, with a maximum of 999 screen captures and save the recording to C:\Temp\PSR_09.07.2016.10-37PM.zip
 .EXAMPLE
Invoke-PSR -Output C:\Temp\PSRRecording.zip -MaxScreenCapture 100 -Start
 This will start psr.exe with the recording started, with a maximum of 100 screen captures and save the recording to C:\Temp\PSRRecording.zip
 .NOTES
Authors and Contributors:
Jeramy Evers
Lynne Taggart

Import-Module "C:\Invoke-PSR\InvokePSR.psm1"
Invoke-PSR -Start -RunAsAdministrator

    .LINK
https://blogs.technet.microsoft.com/allthat/
https://github.com/MSFTZombie/PSRv2

Current Version: 1.0
Date Created: 9/7/2016
Last Modified: 9/7/2016
- Version 4.0 created
- Script edited and tested

#>

 [CmdletBinding()]
Param
(
[parameter(Mandatory=$False)][System.IO.FileInfo]$Output="C:\Temp\$(Get-Date -UFormat "PSR_%m.%d.%Y.%I-%M%p.zip")",
[parameter(Mandatory=$False)][Int][ValidateRange(1,999)]$MaxScreenCapture=999,
[parameter(Mandatory=$False)][Switch]$Start,
[parameter(Mandatory=$False)][Switch]$RunAsAdministrator
)
 $OSVersion = [System.Environment]::OSVersion.Version
 If ($OSVersion.Major -eq 6 -and $OSVersion.Minor -le 1 -and $MaxScreenCapture -gt 100)
{
Write-Warning "PSR.exe on Windows version $($OSVersion.ToString()) has a limitation of a maximum of 100 screen captures and $MaxScreenCapture was specified, so setting maximum screen captures to 100`n"
$MaxScreenCapture = 100
}
 If ((Split-Path $Output -Parent | Test-Path) -eq $False)
{
Write-Warning "$(Split-Path $Output -Parent) doesn't exist. Do you want the directory created?"

Do
{
$KeyPress = Read-Host -Prompt "Y/N"
}
Until ($KeyPress -eq "Y" -or $KeyPress -eq "N")

If ($KeyPress -eq "Y")
{
New-Item $(Split-Path $Output -Parent) -Type Directory
}

  If ($KeyPress -eq "N")
{
Break
}
}
 If ($Start)
{
Write-Host "Starting psr.exe with $MaxScreenCapture maximum screen caputures, recording started and saving to $Output" -ForeGroundColor Green
If ($RunAsAdministrator)
{
Start-Process psr.exe -ArgumentList "/output $Output /maxsc $MaxScreenCapture /start" -Verb RunAs
}
Else
{
Start-Process psr.exe -ArgumentList "/output $Output /maxsc $MaxScreenCapture /start"
}
}
Else
{
Write-Host "Starting psr.exe with $MaxScreenCapture maximum screen caputures and saving to $Output" -ForeGroundColor Green
If ($RunAsAdministrator)
{
Start-Process psr.exe -ArgumentList "/output $Output /maxsc $MaxScreenCapture" -Verb RunAs
}
Else
{
Start-Process psr.exe -ArgumentList "/output $Output /maxsc $MaxScreenCapture"
}
}
}

Export-ModuleMember -Function Invoke-PSR


I hope you enjoy this script.
Comments (0)

Skip to main content