0% found this document useful (0 votes)
240 views4 pages

Troubleshooting Massgrave PowerShell Script

This PowerShell script is designed to troubleshoot issues related to Microsoft Activation Scripts by checking for third-party antivirus interference and ensuring the script runs in Full Language Mode. It retrieves a command script from multiple URLs, verifies its integrity using a hash, and checks for potential issues with the CMD environment. The script also cleans up temporary files created during its execution.

Uploaded by

danilo.souza
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
240 views4 pages

Troubleshooting Massgrave PowerShell Script

This PowerShell script is designed to troubleshoot issues related to Microsoft Activation Scripts by checking for third-party antivirus interference and ensuring the script runs in Full Language Mode. It retrieves a command script from multiple URLs, verifies its integrity using a hash, and checks for potential issues with the CMD environment. The script also cleans up temporary files created during its execution.

Uploaded by

danilo.souza
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

# This script is hosted on [Link] for [Link]

dev

$troubleshoot = '[Link]

if ($[Link].value__ -ne 0) {

$[Link]

Write-Host "Windows PowerShell is not running in Full Language Mode."

Write-Host "Help - [Link] -ForegroundColor White -


BackgroundColor Blue

return

function Check3rdAV {

$avList = Get-CimInstance -Namespace root\SecurityCenter2 -Class


AntiVirusProduct | Where-Object { $_.displayName -notlike '*windows*' } | Select-
Object -ExpandProperty displayName

if ($avList) {

Write-Host '3rd party Antivirus might be blocking the script - ' -ForegroundColor
White -BackgroundColor Blue -NoNewline

Write-Host " $($avList -join ', ')" -ForegroundColor DarkRed -BackgroundColor


White

function CheckFile {

param ([string]$FilePath)

if (-not (Test-Path $FilePath)) {

Check3rdAV

Write-Host "Failed to create MAS file in temp folder, aborting!"

Write-Host "Help - $troubleshoot" -ForegroundColor White -BackgroundColor


Blue
throw

[[Link]]::SecurityProtocol = [[Link]]::Tls12

$URLs = @(

'[Link]
313f240448953cd5fe3c5631f4e4de502f23fc9a/MAS/All-In-One-Version-KL/
MAS_AIO.cmd',

'[Link]
repositories/Microsoft-Activation-Scripts/items?path=/MAS/All-In-One-Version-KL/
MAS_AIO.cmd&versionType=Commit&version=313f240448953cd5fe3c5631f4e4de50
2f23fc9a',

'[Link]
313f240448953cd5fe3c5631f4e4de502f23fc9a/MAS/All-In-One-Version-KL/
MAS_AIO.cmd'

foreach ($URL in $URLs | Sort-Object { Get-Random }) {

try { $response = Invoke-WebRequest -Uri $URL -UseBasicParsing; break } catch


{}

if (-not $response) {

Check3rdAV

Write-Host "Failed to retrieve MAS from any of the available repositories, aborting!"

Write-Host "Help - $troubleshoot" -ForegroundColor White -BackgroundColor Blue

return

# Verify script integrity


$releaseHash =
'919F17B46BF62169E8811201F75EFDF1D5C1504321B78A7B0FB47C335ECBC1B0'

$stream = New-Object [Link]

$writer = New-Object [Link] $stream

$[Link]($response)

$[Link]()

$[Link] = 0

$hash =
[BitConverter]::ToString([[Link].SHA256]::Create().ComputeHash($str
eam)) -replace '-'

if ($hash -ne $releaseHash) {

Write-Warning "Hash ($hash) mismatch, aborting!`nReport this issue at


$troubleshoot"

$response = $null

return

# Check for AutoRun registry which may create issues with CMD

$paths = "HKCU:\SOFTWARE\Microsoft\Command Processor", "HKLM:\SOFTWARE\


Microsoft\Command Processor"

foreach ($path in $paths) {

if (Get-ItemProperty -Path $path -Name "Autorun" -ErrorAction SilentlyContinue) {

Write-Warning "Autorun registry found, CMD may crash! `nManually copy-paste


the below command to fix...`nRemove-ItemProperty -Path '$path' -Name 'Autorun'"

$rand = [Guid]::NewGuid().Guid

$isAdmin = [bool]([[Link]]::GetCurrent().Groups -match


'S-1-5-32-544')

$FilePath = if ($isAdmin) { "$env:SystemRoot\Temp\MAS_$[Link]" } else


{ "$env:USERPROFILE\AppData\Local\Temp\MAS_$[Link]" }
Set-Content -Path $FilePath -Value "@::: $rand `r`n$response"

CheckFile $FilePath

$env:ComSpec = "$env:SystemRoot\system32\[Link]"

$chkcmd = & $env:ComSpec /c "echo CMD is working"

if ($chkcmd -notcontains "CMD is working") {

Write-Warning "[Link] is not working.`nReport this issue at $troubleshoot"

saps -FilePath $env:ComSpec -ArgumentList "/c """"$FilePath"" $args""" -Wait

CheckFile $FilePath

$FilePaths = @("$env:SystemRoot\Temp\MAS*.cmd", "$env:USERPROFILE\AppData\


Local\Temp\MAS*.cmd")

foreach ($FilePath in $FilePaths) { Get-Item $FilePath | Remove-Item }

Common questions

Powered by AI

The script uses the Get-CimInstance command in PowerShell to query the SecurityCenter2 namespace for installed antivirus products, filtering out those that contain 'windows' in their display names. This step is necessary to identify third-party antivirus programs that might block the script's operation, potentially causing it to malfunction .

The script determines the appropriate temporary file path by checking the current user's administrative privileges. If the user has administrative rights, it stores files in the system's temporary folder. Otherwise, it uses the user's profile directory for temporary files. This differentiation ensures compatibility and accessibility of the script files under varying user privilege levels, which is crucial for their successful execution without permission issues .

The script verifies the functionality of 'cmd.exe' by attempting to execute a simple echo command and checks the output. This verification is important because an improperly functioning Command Prompt might prevent the script from executing correctly. If issues are detected, it warns the user and advises reporting the problem to a specified troubleshooting URL .

The script ensures the integrity of the Microsoft Activation Script by calculating the SHA-256 hash of the retrieved script content and comparing it with a pre-defined release hash ('919F17B46BF62169E8811201F75EFDF1D5C1504321B78A7B0FB47C335ECBC1B0'). If there is a mismatch, the script aborts execution and advises reporting the issue to the troubleshoot URL provided .

The script hosted on https://get.activated.win is designed to activate Microsoft products. It includes measures to troubleshoot potential issues such as identifying third-party antivirus software that might block the script and checking file paths to ensure necessary files are accessible. If issues are detected, such as a mismatch in script integrity, antivirus blocks, or cmd.exe not functioning properly, specific warnings are issued along with URLs for further help and instructions for manual fixes .

The script halts execution if it detects that Windows PowerShell is not running in Full Language Mode, if it fails to download the MAS script from available URLs, if the script integrity check fails, or if cmd.exe is not functioning. For each of these issues, the script provides specific instructions such as visiting specific help URLs, manually removing AutoRun registry entries, or reporting malfunctions .

The presence of an 'Autorun' registry entry can cause the Command Prompt (CMD) application to crash, impacting the script's ability to execute correctly. When this entry is detected, the script warns the user and provides a command to manually remove the 'Autorun' entry. This helps ensure that the environment is conducive for script execution and minimizes the risk of interruptions .

The script uses multiple URLs to ensure redundancy, improving its chance of successfully retrieving the MAS script even if one of the URLs is unavailable. It attempts to download from these URLs in a random order and breaks out of the loop upon a successful download. If all download attempts fail, it suggests possible issues with third-party antivirus software and provides a troubleshooting URL .

The script provides a comprehensive set of troubleshooting advice covering various issues such as execution environment checks, antivirus interference, script integrity confirmation, registry entry conflicts, and command line tool functionality. By addressing these aspects, the script enhances its robustness, ensuring that most execution hurdles are anticipated and users are guided effectively to resolve them. The presence of URL references for in-depth troubleshooting further augments the script's capacity to guide users through resolving issues .

The script systematically removes all temporary files it creates in both the system and user-specific temporary directories. This clean-up procedure is critical for maintaining system performance by preventing unnecessary storage consumption and for security by ensuring no residual script fragments remain that could potentially be exploited. This practice upholds best practices for script lifecycle management .

You might also like