Compare commits
3
Commits
b82f741a79
...
f77479c7b7
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f77479c7b7 | ||
|
|
68114af27e | ||
|
|
f4905fec68 |
@@ -1,12 +1,12 @@
|
||||
If ( Is64Bit ) { $BlueScreenView = $Global:ToolsDirectory + '\BlueScreenView-x64.exe' } Else { $BlueScreenView = $Global:ToolsDirectory + '\BlueScreenView-x86.exe' }
|
||||
$BSODReport = $Global:OutputDirectory + '\BSODReport.txt'
|
||||
If ( !(Test-Path $BlueScreenView) ) { Write-Error "File does not exist: ${BlueScreenView}" ; Return }
|
||||
|
||||
# Remove existing BSOD report
|
||||
If ( Test-Path $BSODReport ) { Remove-Item $BSODReport -Force -ErrorAction SilentlyContinue }
|
||||
$BSODReport = $Global:OutputDirectory + '\BSODReport.txt'
|
||||
If ( Test-Path $BSODReport ) { Write-Output "Deleting existing BSOD report: ${BSODReport}" ; Remove-Item $BSODReport -Force -ErrorAction SilentlyContinue }
|
||||
|
||||
# Run BlueScreenView
|
||||
If ( !(Test-Path $BlueScreenView) ) { Write-Error "File does not exist: ${BlueScreenView}" ; Return }
|
||||
Start-Process $BlueScreenView -ArgumentList "/stext $BSODReport /sort ~1" -Wait
|
||||
Start-Process $BlueScreenView -ArgumentList "/stext ${BSODReport} /sort ~1" -Wait
|
||||
|
||||
# Wait for BSOD report
|
||||
For ($i = 0; $i -lt 1200; $i++) {
|
||||
@@ -33,19 +33,11 @@ $ProviderMicrosoft = 'Microsoft|Windows'
|
||||
# Get the provider data from the most recent BSOD
|
||||
$CulpritProvider = $BSODReportContent[12..13] -join '`n'
|
||||
|
||||
# Set the billable time
|
||||
$BillableTimeInMinutes = 15
|
||||
$StartAt = (Get-Date).AddMinutes(-$BillableTimeInMinutes).ToString("o")
|
||||
|
||||
Switch ( $CulpritProvider ) {
|
||||
{ $_ -match $ProviderMicrosoft } {
|
||||
New-TicketComment -Comment "I've analyzed the crash report and it indicates a problem with a Windows component. I'll repair the system now."
|
||||
$TimeEntryNote = "Analysis indicates crash caused by Windows component(s). Scanning and repairing corruption in the system."
|
||||
Create-Syncro-Ticket-TimerEntry -TicketIdOrNumber $TicketID -StartTime $StartAt -DurationMinutes $BillableTimeInMinutes -Notes $TimeEntryNote -UserIdOrEmail $TimeAttributedToUser -ChargeTime "true"
|
||||
$FixWindowsHealth = Download-File -URL 'https://dev.emberkom.com/emberkom/management-scripts/raw/branch/master/Fix-WindowsHealth.ps1'
|
||||
Start-Sleep -Seconds 120
|
||||
. $FixWindowsHealth
|
||||
If ( Test-Path $FixWindowsHealth ) { Remove-Item $FixWindowsHealth -Force -ErrorAction SilentlyContinue }
|
||||
New-TicketTimerEntry -Comment "Analysis indicates crash caused by Windows component(s). Scanning and repairing corruption in the system."
|
||||
Source-PSScript -ScriptName "Fix-WindowsHealth"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
# Check the RMM runtime variable to see if it's set to 'null', if not then set the $TicketID
|
||||
If ( $TicketNumber.Trim().ToLower() -ne 'null' ) { $Global:TicketNumber = $TicketNumber.Trim() }
|
||||
|
||||
# Run SFC to check the filesystem, convert the result from Unicode to UTF8, delete the intermediate $tempFile
|
||||
$tempFile = New-TemporaryFile
|
||||
$(sfc.exe /scannow) | Out-File $tempFile
|
||||
|
||||
@@ -12,8 +12,9 @@
|
||||
# Define the root path for the MSP in the Windows Registry
|
||||
[string]$Global:MSPRegistryRoot = "HKEY_LOCAL_MACHINE\SOFTWARE\${MSPName}"
|
||||
|
||||
# Create a global variable to keep a ticket number if it needs to be used by any scripts
|
||||
# Create a global variable to keep a ticket and billing related variables if they are needed later
|
||||
$Global:TicketNumber = $null
|
||||
$Global:TimeAttributedToUser = ""
|
||||
|
||||
# Setup the MSP management directories
|
||||
Function Setup-MSPDirectories {
|
||||
@@ -1017,9 +1018,10 @@ Function Restart-EndpointOnUptime ([timespan]$MaxUptime) {
|
||||
Catch { Write-Error $_.Exception.Message }
|
||||
}
|
||||
|
||||
# Function to download and install local tools used by scripts
|
||||
Function Install-LocalTools () {
|
||||
param(
|
||||
[Parameter(ValueFromPipeline=$false,Mandatory=$false)][switch]$Force
|
||||
[Parameter(ValueFromPipeline=$false,Mandatory=$false)][switch]$Force=$false
|
||||
)
|
||||
|
||||
$ToolURLs = @(
|
||||
@@ -1040,24 +1042,39 @@ Function Install-LocalTools () {
|
||||
}
|
||||
}
|
||||
|
||||
Function Source-PSScript ([string]$ScriptName) {
|
||||
If ( $ScriptName.StartsWith('http://') -or $ScriptName.StartsWith('https://') ) {
|
||||
$URL = $ScriptName
|
||||
} Else {
|
||||
$URL = "https://dev.emberkom.com/emberkom/management-scripts/raw/branch/master/${ScriptName}.ps1"
|
||||
}
|
||||
$ScriptFile = Download-File -URL $URL
|
||||
Write-Output "Sourcing ${ScriptFile}"
|
||||
. $ScriptFile
|
||||
If ( Test-Path $ScriptFile ) { Write-Output "Removing ${ScriptFile}" ; Remove-Item $ScriptFile -Force -ErrorAction SilentlyContinue }
|
||||
}
|
||||
|
||||
# Function to import the Syncro Module
|
||||
Function Import-RMMModule () {
|
||||
Try { Import-Module $env:SyncroModule -WarningAction SilentlyContinue -ErrorAction Stop }
|
||||
Catch { Write-Error $_.Exception.Message ; Return }
|
||||
}
|
||||
|
||||
# Function to create a new ticket
|
||||
Function New-RMMTicket () {
|
||||
param(
|
||||
[Parameter(ValueFromPipeline=$false,Mandatory=$true)][string]$Subject,
|
||||
[Parameter(ValueFromPipeline=$false,Mandatory=$false)][string]$IssueType="Remote Support",
|
||||
[Parameter(ValueFromPipeline=$false,Mandatory=$true)][string]$InitialIssue
|
||||
)
|
||||
Import-RMMModule
|
||||
If ( !(Get-Command Create-Syncro-Ticket -ErrorAction SilentlyContinue) ) { Import-RMMModule}
|
||||
Try { $Ticket = Create-Syncro-Ticket -Subject $Subject -IssueType $IssueType -Status "New" }
|
||||
Catch { Write-Error $_.Exception.Message ; Return }
|
||||
$Global:TicketNumber = $Ticket.ticket.id
|
||||
New-TicketComment -TicketID $Global:TicketNumber -Subject "Issue" -Comment $InitialIssue -Hidden -DoNotEmail
|
||||
}
|
||||
|
||||
# Function to create a new comment on a ticket
|
||||
Function New-TicketComment () {
|
||||
param(
|
||||
[Parameter(ValueFromPipeline=$false,Mandatory=$false)]$TicketID=$null,
|
||||
@@ -1066,12 +1083,37 @@ Function New-TicketComment () {
|
||||
[Parameter(ValueFromPipeline=$false,Mandatory=$false)][switch]$Hidden=$false,
|
||||
[Parameter(ValueFromPipeline=$false,Mandatory=$false)][switch]$DoNotEmail=$false
|
||||
)
|
||||
If ( !(Get-Command Create-Syncro-Ticket-Comment -ErrorAction SilentlyContinue) ) { Import-RMMModule}
|
||||
If ( ($null -eq $TicketID) -and ($null -eq $Global:TicketNumber) ) { Return }
|
||||
If ( ($null -eq $TicketID) -and ($null -ne $Global:TicketNumber) ) { $TicketID = $Global:TicketNumber }
|
||||
Try { Create-Syncro-Ticket-Comment -TicketIdOrNumber $TicketID -Subject $Subject -Body $Comment -Hidden $Hidden -DoNotEmail $DoNotEmail }
|
||||
Catch { Write-Error $_.Exception.Message ; Return }
|
||||
}
|
||||
|
||||
# Function to create a new billable time entry on a ticket
|
||||
Function New-TicketTimerEntry () {
|
||||
param(
|
||||
[Parameter(ValueFromPipeline=$false,Mandatory=$false)]$TicketID=$null,
|
||||
[Parameter(ValueFromPipeline=$false,Mandatory=$false)][int]$BillableMinutes=15,
|
||||
[Parameter(ValueFromPipeline=$true,Mandatory=$true)][string]$Comment,
|
||||
[Parameter(ValueFromPipeline=$false,Mandatory=$false)][string]$BillableUser=$Global:TimeAttributedToUser,
|
||||
[Parameter(ValueFromPipeline=$false,Mandatory=$false)][switch]$ChargeLater=$false
|
||||
)
|
||||
If ( $BillableUser -eq "" ) { Write-Error "Billable user not specified" ; Return }
|
||||
If ( !(Get-Command Create-Syncro-Ticket-TimerEntry -ErrorAction SilentlyContinue) ) { Import-RMMModule}
|
||||
If ( $ChargeLater -eq $true ) { $ChargeTime = "false" } Else { $ChargeTime = "true" }
|
||||
$StartAt = (Get-Date).AddMinutes(-$BillableMinutes).ToString("o")
|
||||
Create-Syncro-Ticket-TimerEntry -TicketIdOrNumber $TicketID -StartTime $StartAt -DurationMinutes $BillableMinutes -Notes $Comment -UserIdOrEmail $BillableUser -ChargeTime $ChargeTime
|
||||
}
|
||||
|
||||
# Initial setup of the MSP management directories and log file
|
||||
Setup-MSPDirectories
|
||||
Setup-LogFile
|
||||
|
||||
# Install the local tools
|
||||
Install-LocalTools
|
||||
|
||||
# Check the RMM runtime variable to see if a billable user was specified, if so then set the $TimeAttributedToUser
|
||||
If ( $TimeAttributedToUser.Trim().Length -ge 6 ) { $Global:TimeAttributedToUser = $TimeAttributedToUser.Trim().ToLower() }
|
||||
# Check the RMM runtime variable to see if a ticket number was specified, if so then set the $TicketID
|
||||
If ( $TicketNumber.Trim().Length -gt 1 ) { $Global:TicketNumber = $TicketNumber.Trim() }
|
||||
Reference in New Issue
Block a user