diff --git a/MAS/All-In-One-Version-KL/MAS_AIO.cmd b/MAS/All-In-One-Version-KL/MAS_AIO.cmd index 11b8ec9..06e4d83 100644 --- a/MAS/All-In-One-Version-KL/MAS_AIO.cmd +++ b/MAS/All-In-One-Version-KL/MAS_AIO.cmd @@ -196,11 +196,18 @@ goto dk_done ::pstst $ExecutionContext.SessionState.LanguageMode :pstst -for /f "delims=" %%a in ('cmd /c "%psc% ""$f=[io.file]::ReadAllText('!_batp!') -split ':pstst';iex ($f[1])""" %nul6%') do (set tstresult=%%a) +for /f "delims=" %%a in ('cmd /c "%psc% ""if ($PSVersionTable.PSEdition -ne 'Core') {$f=[io.file]::ReadAllText('!_batp!') -split ':pstst';iex ($f[1])}""" %nul6%') do (set tstresult=%%a) -if /i "%tstresult%"=="ConstrainedLanguage" ( +if /i not "%tstresult%"=="FullLanguage" ( %eline% -echo ConstrainedLanguage mode found in PowerShell. Aborting... +echo %tstresult% +cmd /c "%psc% $ExecutionContext.SessionState.LanguageMode" + +REM check LanguageMode + +cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" | findstr /i "ConstrainedLanguage RestrictedLanguage NoLanguage" %nul1% && ( +%eline% +echo FullLanguage mode not found in PowerShell. Aborting... echo If you have applied restrictions on Powershell then undo those changes. echo: set fixes=%fixes% %mas%fix_powershell @@ -208,10 +215,15 @@ call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%fix_powershell" goto dk_done ) -if /i not "%tstresult%"=="FullLanguage" ( -%eline% -echo "%tstresult%" -cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" +REM check Powershell core version + +cmd /c "%psc% "$PSVersionTable.PSEdition"" | find /i "Core" %nul1% && ( +echo Windows Powershell is needed for MAS but it seems to be replaced with Powershell core. Aborting... +goto dk_done +) + +REM check antivirus and other errors + echo PowerShell is not working properly. Aborting... cmd /c "%psc% ""$av = Get-WmiObject -Namespace root\SecurityCenter2 -Class AntiVirusProduct; $n = @(); foreach ($i in $av) { if ($i.displayName -notlike '*windows*') { $n += $i.displayName } }; if ($n) { Write-Host ('Installed 3rd party Antivirus might be blocking the script - ' + ($n -join ', ')) -ForegroundColor White -BackgroundColor Blue }""" echo: diff --git a/MAS/Separate-Files-Version/Activators/HWID_Activation.cmd b/MAS/Separate-Files-Version/Activators/HWID_Activation.cmd index fa3786a..2730ec6 100644 --- a/MAS/Separate-Files-Version/Activators/HWID_Activation.cmd +++ b/MAS/Separate-Files-Version/Activators/HWID_Activation.cmd @@ -235,11 +235,18 @@ goto dk_done ::pstst $ExecutionContext.SessionState.LanguageMode :pstst -for /f "delims=" %%a in ('cmd /c "%psc% ""$f=[io.file]::ReadAllText('!_batp!') -split ':pstst';iex ($f[1])""" %nul6%') do (set tstresult=%%a) +for /f "delims=" %%a in ('cmd /c "%psc% ""if ($PSVersionTable.PSEdition -ne 'Core') {$f=[io.file]::ReadAllText('!_batp!') -split ':pstst';iex ($f[1])}""" %nul6%') do (set tstresult=%%a) -if /i "%tstresult%"=="ConstrainedLanguage" ( +if /i not "%tstresult%"=="FullLanguage" ( %eline% -echo ConstrainedLanguage mode found in PowerShell. Aborting... +echo %tstresult% +cmd /c "%psc% $ExecutionContext.SessionState.LanguageMode" + +REM check LanguageMode + +cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" | findstr /i "ConstrainedLanguage RestrictedLanguage NoLanguage" %nul1% && ( +%eline% +echo FullLanguage mode not found in PowerShell. Aborting... echo If you have applied restrictions on Powershell then undo those changes. echo: set fixes=%fixes% %mas%fix_powershell @@ -247,10 +254,15 @@ call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%fix_powershell" goto dk_done ) -if /i not "%tstresult%"=="FullLanguage" ( -%eline% -echo "%tstresult%" -cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" +REM check Powershell core version + +cmd /c "%psc% "$PSVersionTable.PSEdition"" | find /i "Core" %nul1% && ( +echo Windows Powershell is needed for MAS but it seems to be replaced with Powershell core. Aborting... +goto dk_done +) + +REM check antivirus and other errors + echo PowerShell is not working properly. Aborting... cmd /c "%psc% ""$av = Get-WmiObject -Namespace root\SecurityCenter2 -Class AntiVirusProduct; $n = @(); foreach ($i in $av) { if ($i.displayName -notlike '*windows*') { $n += $i.displayName } }; if ($n) { Write-Host ('Installed 3rd party Antivirus might be blocking the script - ' + ($n -join ', ')) -ForegroundColor White -BackgroundColor Blue }""" echo: diff --git a/MAS/Separate-Files-Version/Activators/KMS38_Activation.cmd b/MAS/Separate-Files-Version/Activators/KMS38_Activation.cmd index eeee718..19586c1 100644 --- a/MAS/Separate-Files-Version/Activators/KMS38_Activation.cmd +++ b/MAS/Separate-Files-Version/Activators/KMS38_Activation.cmd @@ -238,11 +238,18 @@ goto dk_done ::pstst $ExecutionContext.SessionState.LanguageMode :pstst -for /f "delims=" %%a in ('cmd /c "%psc% ""$f=[io.file]::ReadAllText('!_batp!') -split ':pstst';iex ($f[1])""" %nul6%') do (set tstresult=%%a) +for /f "delims=" %%a in ('cmd /c "%psc% ""if ($PSVersionTable.PSEdition -ne 'Core') {$f=[io.file]::ReadAllText('!_batp!') -split ':pstst';iex ($f[1])}""" %nul6%') do (set tstresult=%%a) -if /i "%tstresult%"=="ConstrainedLanguage" ( +if /i not "%tstresult%"=="FullLanguage" ( %eline% -echo ConstrainedLanguage mode found in PowerShell. Aborting... +echo %tstresult% +cmd /c "%psc% $ExecutionContext.SessionState.LanguageMode" + +REM check LanguageMode + +cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" | findstr /i "ConstrainedLanguage RestrictedLanguage NoLanguage" %nul1% && ( +%eline% +echo FullLanguage mode not found in PowerShell. Aborting... echo If you have applied restrictions on Powershell then undo those changes. echo: set fixes=%fixes% %mas%fix_powershell @@ -250,10 +257,15 @@ call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%fix_powershell" goto dk_done ) -if /i not "%tstresult%"=="FullLanguage" ( -%eline% -echo "%tstresult%" -cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" +REM check Powershell core version + +cmd /c "%psc% "$PSVersionTable.PSEdition"" | find /i "Core" %nul1% && ( +echo Windows Powershell is needed for MAS but it seems to be replaced with Powershell core. Aborting... +goto dk_done +) + +REM check antivirus and other errors + echo PowerShell is not working properly. Aborting... cmd /c "%psc% ""$av = Get-WmiObject -Namespace root\SecurityCenter2 -Class AntiVirusProduct; $n = @(); foreach ($i in $av) { if ($i.displayName -notlike '*windows*') { $n += $i.displayName } }; if ($n) { Write-Host ('Installed 3rd party Antivirus might be blocking the script - ' + ($n -join ', ')) -ForegroundColor White -BackgroundColor Blue }""" echo: diff --git a/MAS/Separate-Files-Version/Activators/Ohook_Activation_AIO.cmd b/MAS/Separate-Files-Version/Activators/Ohook_Activation_AIO.cmd index a1679e1..53860bd 100644 --- a/MAS/Separate-Files-Version/Activators/Ohook_Activation_AIO.cmd +++ b/MAS/Separate-Files-Version/Activators/Ohook_Activation_AIO.cmd @@ -228,11 +228,18 @@ goto dk_done ::pstst $ExecutionContext.SessionState.LanguageMode :pstst -for /f "delims=" %%a in ('cmd /c "%psc% ""$f=[io.file]::ReadAllText('!_batp!') -split ':pstst';iex ($f[1])""" %nul6%') do (set tstresult=%%a) +for /f "delims=" %%a in ('cmd /c "%psc% ""if ($PSVersionTable.PSEdition -ne 'Core') {$f=[io.file]::ReadAllText('!_batp!') -split ':pstst';iex ($f[1])}""" %nul6%') do (set tstresult=%%a) -if /i "%tstresult%"=="ConstrainedLanguage" ( +if /i not "%tstresult%"=="FullLanguage" ( %eline% -echo ConstrainedLanguage mode found in PowerShell. Aborting... +echo %tstresult% +cmd /c "%psc% $ExecutionContext.SessionState.LanguageMode" + +REM check LanguageMode + +cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" | findstr /i "ConstrainedLanguage RestrictedLanguage NoLanguage" %nul1% && ( +%eline% +echo FullLanguage mode not found in PowerShell. Aborting... echo If you have applied restrictions on Powershell then undo those changes. echo: set fixes=%fixes% %mas%fix_powershell @@ -240,10 +247,15 @@ call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%fix_powershell" goto dk_done ) -if /i not "%tstresult%"=="FullLanguage" ( -%eline% -echo "%tstresult%" -cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" +REM check Powershell core version + +cmd /c "%psc% "$PSVersionTable.PSEdition"" | find /i "Core" %nul1% && ( +echo Windows Powershell is needed for MAS but it seems to be replaced with Powershell core. Aborting... +goto dk_done +) + +REM check antivirus and other errors + echo PowerShell is not working properly. Aborting... cmd /c "%psc% ""$av = Get-WmiObject -Namespace root\SecurityCenter2 -Class AntiVirusProduct; $n = @(); foreach ($i in $av) { if ($i.displayName -notlike '*windows*') { $n += $i.displayName } }; if ($n) { Write-Host ('Installed 3rd party Antivirus might be blocking the script - ' + ($n -join ', ')) -ForegroundColor White -BackgroundColor Blue }""" echo: diff --git a/MAS/Separate-Files-Version/Activators/Online_KMS_Activation.cmd b/MAS/Separate-Files-Version/Activators/Online_KMS_Activation.cmd index e14f24b..2a15a50 100644 --- a/MAS/Separate-Files-Version/Activators/Online_KMS_Activation.cmd +++ b/MAS/Separate-Files-Version/Activators/Online_KMS_Activation.cmd @@ -257,11 +257,18 @@ goto dk_done ::pstst $ExecutionContext.SessionState.LanguageMode :pstst -for /f "delims=" %%a in ('cmd /c "%psc% ""$f=[io.file]::ReadAllText('!_batp!') -split ':pstst';iex ($f[1])""" %nul6%') do (set tstresult=%%a) +for /f "delims=" %%a in ('cmd /c "%psc% ""if ($PSVersionTable.PSEdition -ne 'Core') {$f=[io.file]::ReadAllText('!_batp!') -split ':pstst';iex ($f[1])}""" %nul6%') do (set tstresult=%%a) -if /i "%tstresult%"=="ConstrainedLanguage" ( +if /i not "%tstresult%"=="FullLanguage" ( %eline% -echo ConstrainedLanguage mode found in PowerShell. Aborting... +echo %tstresult% +cmd /c "%psc% $ExecutionContext.SessionState.LanguageMode" + +REM check LanguageMode + +cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" | findstr /i "ConstrainedLanguage RestrictedLanguage NoLanguage" %nul1% && ( +%eline% +echo FullLanguage mode not found in PowerShell. Aborting... echo If you have applied restrictions on Powershell then undo those changes. echo: set fixes=%fixes% %mas%fix_powershell @@ -269,10 +276,15 @@ call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%fix_powershell" goto dk_done ) -if /i not "%tstresult%"=="FullLanguage" ( -%eline% -echo "%tstresult%" -cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" +REM check Powershell core version + +cmd /c "%psc% "$PSVersionTable.PSEdition"" | find /i "Core" %nul1% && ( +echo Windows Powershell is needed for MAS but it seems to be replaced with Powershell core. Aborting... +goto dk_done +) + +REM check antivirus and other errors + echo PowerShell is not working properly. Aborting... cmd /c "%psc% ""$av = Get-WmiObject -Namespace root\SecurityCenter2 -Class AntiVirusProduct; $n = @(); foreach ($i in $av) { if ($i.displayName -notlike '*windows*') { $n += $i.displayName } }; if ($n) { Write-Host ('Installed 3rd party Antivirus might be blocking the script - ' + ($n -join ', ')) -ForegroundColor White -BackgroundColor Blue }""" echo: diff --git a/MAS/Separate-Files-Version/Activators/TSforge_Activation.cmd b/MAS/Separate-Files-Version/Activators/TSforge_Activation.cmd index 96a273c..3067851 100644 --- a/MAS/Separate-Files-Version/Activators/TSforge_Activation.cmd +++ b/MAS/Separate-Files-Version/Activators/TSforge_Activation.cmd @@ -263,11 +263,18 @@ goto dk_done ::pstst $ExecutionContext.SessionState.LanguageMode :pstst -for /f "delims=" %%a in ('cmd /c "%psc% ""$f=[io.file]::ReadAllText('!_batp!') -split ':pstst';iex ($f[1])""" %nul6%') do (set tstresult=%%a) +for /f "delims=" %%a in ('cmd /c "%psc% ""if ($PSVersionTable.PSEdition -ne 'Core') {$f=[io.file]::ReadAllText('!_batp!') -split ':pstst';iex ($f[1])}""" %nul6%') do (set tstresult=%%a) -if /i "%tstresult%"=="ConstrainedLanguage" ( +if /i not "%tstresult%"=="FullLanguage" ( %eline% -echo ConstrainedLanguage mode found in PowerShell. Aborting... +echo %tstresult% +cmd /c "%psc% $ExecutionContext.SessionState.LanguageMode" + +REM check LanguageMode + +cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" | findstr /i "ConstrainedLanguage RestrictedLanguage NoLanguage" %nul1% && ( +%eline% +echo FullLanguage mode not found in PowerShell. Aborting... echo If you have applied restrictions on Powershell then undo those changes. echo: set fixes=%fixes% %mas%fix_powershell @@ -275,10 +282,15 @@ call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%fix_powershell" goto dk_done ) -if /i not "%tstresult%"=="FullLanguage" ( -%eline% -echo "%tstresult%" -cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" +REM check Powershell core version + +cmd /c "%psc% "$PSVersionTable.PSEdition"" | find /i "Core" %nul1% && ( +echo Windows Powershell is needed for MAS but it seems to be replaced with Powershell core. Aborting... +goto dk_done +) + +REM check antivirus and other errors + echo PowerShell is not working properly. Aborting... cmd /c "%psc% ""$av = Get-WmiObject -Namespace root\SecurityCenter2 -Class AntiVirusProduct; $n = @(); foreach ($i in $av) { if ($i.displayName -notlike '*windows*') { $n += $i.displayName } }; if ($n) { Write-Host ('Installed 3rd party Antivirus might be blocking the script - ' + ($n -join ', ')) -ForegroundColor White -BackgroundColor Blue }""" echo: diff --git a/MAS/Separate-Files-Version/Change_Office_Edition.cmd b/MAS/Separate-Files-Version/Change_Office_Edition.cmd index 6ec47b5..95d4044 100644 --- a/MAS/Separate-Files-Version/Change_Office_Edition.cmd +++ b/MAS/Separate-Files-Version/Change_Office_Edition.cmd @@ -188,11 +188,18 @@ goto dk_done ::pstst $ExecutionContext.SessionState.LanguageMode :pstst -for /f "delims=" %%a in ('cmd /c "%psc% ""$f=[io.file]::ReadAllText('!_batp!') -split ':pstst';iex ($f[1])""" %nul6%') do (set tstresult=%%a) +for /f "delims=" %%a in ('cmd /c "%psc% ""if ($PSVersionTable.PSEdition -ne 'Core') {$f=[io.file]::ReadAllText('!_batp!') -split ':pstst';iex ($f[1])}""" %nul6%') do (set tstresult=%%a) -if /i "%tstresult%"=="ConstrainedLanguage" ( +if /i not "%tstresult%"=="FullLanguage" ( %eline% -echo ConstrainedLanguage mode found in PowerShell. Aborting... +echo %tstresult% +cmd /c "%psc% $ExecutionContext.SessionState.LanguageMode" + +REM check LanguageMode + +cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" | findstr /i "ConstrainedLanguage RestrictedLanguage NoLanguage" %nul1% && ( +%eline% +echo FullLanguage mode not found in PowerShell. Aborting... echo If you have applied restrictions on Powershell then undo those changes. echo: set fixes=%fixes% %mas%fix_powershell @@ -200,10 +207,15 @@ call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%fix_powershell" goto dk_done ) -if /i not "%tstresult%"=="FullLanguage" ( -%eline% -echo "%tstresult%" -cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" +REM check Powershell core version + +cmd /c "%psc% "$PSVersionTable.PSEdition"" | find /i "Core" %nul1% && ( +echo Windows Powershell is needed for MAS but it seems to be replaced with Powershell core. Aborting... +goto dk_done +) + +REM check antivirus and other errors + echo PowerShell is not working properly. Aborting... cmd /c "%psc% ""$av = Get-WmiObject -Namespace root\SecurityCenter2 -Class AntiVirusProduct; $n = @(); foreach ($i in $av) { if ($i.displayName -notlike '*windows*') { $n += $i.displayName } }; if ($n) { Write-Host ('Installed 3rd party Antivirus might be blocking the script - ' + ($n -join ', ')) -ForegroundColor White -BackgroundColor Blue }""" echo: diff --git a/MAS/Separate-Files-Version/Change_Windows_Edition.cmd b/MAS/Separate-Files-Version/Change_Windows_Edition.cmd index 19c1c3a..10a1559 100644 --- a/MAS/Separate-Files-Version/Change_Windows_Edition.cmd +++ b/MAS/Separate-Files-Version/Change_Windows_Edition.cmd @@ -193,11 +193,18 @@ goto dk_done ::pstst $ExecutionContext.SessionState.LanguageMode :pstst -for /f "delims=" %%a in ('cmd /c "%psc% ""$f=[io.file]::ReadAllText('!_batp!') -split ':pstst';iex ($f[1])""" %nul6%') do (set tstresult=%%a) +for /f "delims=" %%a in ('cmd /c "%psc% ""if ($PSVersionTable.PSEdition -ne 'Core') {$f=[io.file]::ReadAllText('!_batp!') -split ':pstst';iex ($f[1])}""" %nul6%') do (set tstresult=%%a) -if /i "%tstresult%"=="ConstrainedLanguage" ( +if /i not "%tstresult%"=="FullLanguage" ( %eline% -echo ConstrainedLanguage mode found in PowerShell. Aborting... +echo %tstresult% +cmd /c "%psc% $ExecutionContext.SessionState.LanguageMode" + +REM check LanguageMode + +cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" | findstr /i "ConstrainedLanguage RestrictedLanguage NoLanguage" %nul1% && ( +%eline% +echo FullLanguage mode not found in PowerShell. Aborting... echo If you have applied restrictions on Powershell then undo those changes. echo: set fixes=%fixes% %mas%fix_powershell @@ -205,10 +212,15 @@ call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%fix_powershell" goto dk_done ) -if /i not "%tstresult%"=="FullLanguage" ( -%eline% -echo "%tstresult%" -cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" +REM check Powershell core version + +cmd /c "%psc% "$PSVersionTable.PSEdition"" | find /i "Core" %nul1% && ( +echo Windows Powershell is needed for MAS but it seems to be replaced with Powershell core. Aborting... +goto dk_done +) + +REM check antivirus and other errors + echo PowerShell is not working properly. Aborting... cmd /c "%psc% ""$av = Get-WmiObject -Namespace root\SecurityCenter2 -Class AntiVirusProduct; $n = @(); foreach ($i in $av) { if ($i.displayName -notlike '*windows*') { $n += $i.displayName } }; if ($n) { Write-Host ('Installed 3rd party Antivirus might be blocking the script - ' + ($n -join ', ')) -ForegroundColor White -BackgroundColor Blue }""" echo: diff --git a/MAS/Separate-Files-Version/Extract_OEM_Folder.cmd b/MAS/Separate-Files-Version/Extract_OEM_Folder.cmd index c1b78c1..7c8c3d4 100644 --- a/MAS/Separate-Files-Version/Extract_OEM_Folder.cmd +++ b/MAS/Separate-Files-Version/Extract_OEM_Folder.cmd @@ -187,11 +187,18 @@ goto done2 ::pstst $ExecutionContext.SessionState.LanguageMode :pstst -for /f "delims=" %%a in ('cmd /c "%psc% ""$f=[io.file]::ReadAllText('!_batp!') -split ':pstst';iex ($f[1])""" %nul6%') do (set tstresult=%%a) +for /f "delims=" %%a in ('cmd /c "%psc% ""if ($PSVersionTable.PSEdition -ne 'Core') {$f=[io.file]::ReadAllText('!_batp!') -split ':pstst';iex ($f[1])}""" %nul6%') do (set tstresult=%%a) -if /i "%tstresult%"=="ConstrainedLanguage" ( +if /i not "%tstresult%"=="FullLanguage" ( %eline% -echo ConstrainedLanguage mode found in PowerShell. Aborting... +echo %tstresult% +cmd /c "%psc% $ExecutionContext.SessionState.LanguageMode" + +REM check LanguageMode + +cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" | findstr /i "ConstrainedLanguage RestrictedLanguage NoLanguage" %nul1% && ( +%eline% +echo FullLanguage mode not found in PowerShell. Aborting... echo If you have applied restrictions on Powershell then undo those changes. echo: set fixes=%fixes% %mas%fix_powershell @@ -199,10 +206,15 @@ call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%fix_powershell" goto done2 ) -if /i not "%tstresult%"=="FullLanguage" ( -%eline% -echo "%tstresult%" -cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" +REM check Powershell core version + +cmd /c "%psc% "$PSVersionTable.PSEdition"" | find /i "Core" %nul1% && ( +echo Windows Powershell is needed for MAS but it seems to be replaced with Powershell core. Aborting... +goto done2 +) + +REM check antivirus and other errors + echo PowerShell is not working properly. Aborting... cmd /c "%psc% ""$av = Get-WmiObject -Namespace root\SecurityCenter2 -Class AntiVirusProduct; $n = @(); foreach ($i in $av) { if ($i.displayName -notlike '*windows*') { $n += $i.displayName } }; if ($n) { Write-Host ('Installed 3rd party Antivirus might be blocking the script - ' + ($n -join ', ')) -ForegroundColor White -BackgroundColor Blue }""" echo: diff --git a/MAS/Separate-Files-Version/Troubleshoot.cmd b/MAS/Separate-Files-Version/Troubleshoot.cmd index 73cb0c4..8ce62b7 100644 --- a/MAS/Separate-Files-Version/Troubleshoot.cmd +++ b/MAS/Separate-Files-Version/Troubleshoot.cmd @@ -188,11 +188,18 @@ goto dk_done ::pstst $ExecutionContext.SessionState.LanguageMode :pstst -for /f "delims=" %%a in ('cmd /c "%psc% ""$f=[io.file]::ReadAllText('!_batp!') -split ':pstst';iex ($f[1])""" %nul6%') do (set tstresult=%%a) +for /f "delims=" %%a in ('cmd /c "%psc% ""if ($PSVersionTable.PSEdition -ne 'Core') {$f=[io.file]::ReadAllText('!_batp!') -split ':pstst';iex ($f[1])}""" %nul6%') do (set tstresult=%%a) -if /i "%tstresult%"=="ConstrainedLanguage" ( +if /i not "%tstresult%"=="FullLanguage" ( %eline% -echo ConstrainedLanguage mode found in PowerShell. Aborting... +echo %tstresult% +cmd /c "%psc% $ExecutionContext.SessionState.LanguageMode" + +REM check LanguageMode + +cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" | findstr /i "ConstrainedLanguage RestrictedLanguage NoLanguage" %nul1% && ( +%eline% +echo FullLanguage mode not found in PowerShell. Aborting... echo If you have applied restrictions on Powershell then undo those changes. echo: set fixes=%fixes% %mas%fix_powershell @@ -200,10 +207,15 @@ call :dk_color2 %Blue% "Help - " %_Yellow% " %mas%fix_powershell" goto dk_done ) -if /i not "%tstresult%"=="FullLanguage" ( -%eline% -echo "%tstresult%" -cmd /c "%psc% "$ExecutionContext.SessionState.LanguageMode"" +REM check Powershell core version + +cmd /c "%psc% "$PSVersionTable.PSEdition"" | find /i "Core" %nul1% && ( +echo Windows Powershell is needed for MAS but it seems to be replaced with Powershell core. Aborting... +goto dk_done +) + +REM check antivirus and other errors + echo PowerShell is not working properly. Aborting... cmd /c "%psc% ""$av = Get-WmiObject -Namespace root\SecurityCenter2 -Class AntiVirusProduct; $n = @(); foreach ($i in $av) { if ($i.displayName -notlike '*windows*') { $n += $i.displayName } }; if ($n) { Write-Host ('Installed 3rd party Antivirus might be blocking the script - ' + ($n -join ', ')) -ForegroundColor White -BackgroundColor Blue }""" echo: