Upload files to "Microsoft"
This commit is contained in:
parent
5aa62e0923
commit
cd5f20d2cf
55
Microsoft/Run_System_File_Checker.ps1
Normal file
55
Microsoft/Run_System_File_Checker.ps1
Normal file
|
|
@ -0,0 +1,55 @@
|
||||||
|
# Script by Timur@0x01337.com
|
||||||
|
# Date: 2023-11-24
|
||||||
|
<#
|
||||||
|
.DESCRIPTION
|
||||||
|
Runs the "sfc /scannow" command that finds and fixes errors in Windows system files and returns the result of operation.
|
||||||
|
|
||||||
|
Requires administrator privileges.
|
||||||
|
|
||||||
|
.PARAMETER help
|
||||||
|
Displays a detailed usage description of this script.
|
||||||
|
|
||||||
|
.EXAMPLE
|
||||||
|
PS> .\Run-System-File-Checker.ps1
|
||||||
|
|
||||||
|
.EXAMPLE
|
||||||
|
PS> .\Run-System-File-Checker.ps1 -help
|
||||||
|
#>
|
||||||
|
|
||||||
|
# Getting command line parameters
|
||||||
|
param (
|
||||||
|
[parameter(Mandatory = $false)][switch]$help
|
||||||
|
)
|
||||||
|
|
||||||
|
$currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
|
||||||
|
$isAdmin = $currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
|
||||||
|
if (!$isAdmin) {
|
||||||
|
Write-Error "This script requires administrator privileges"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Writing help message
|
||||||
|
if ($help) {
|
||||||
|
get-help $MyInvocation.MyCommand.Path -Full
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
$command = "sfc"
|
||||||
|
$arguments = "/scannow"
|
||||||
|
|
||||||
|
Write-Host "Running $command $arguments"
|
||||||
|
try {
|
||||||
|
$process = Start-Process -Wait -PassThru -NoNewWindow -FilePath $command -ArgumentList $arguments
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
Write-Error "$_, exit code: $($process.ExitCode)"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$process -or $process.ExitCode -ne 0) {
|
||||||
|
Write-Error "$command $arguments failed, exit code: $($process.ExitCode)"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "$command $arguments finish, exit code: $($process.ExitCode)"
|
||||||
|
exit 0
|
||||||
Loading…
Reference in a new issue