Local_PSTools_Manager_v3.0.ps1, Windows sistem yöneticileri için hazırlanmış menü tabanlı bir PowerShell yönetim betiğidir. Betik, Microsoft Sysinternals PSTools bileşenlerini tek bir konsol üzerinden çalıştırarak sistem bilgisi toplama, süreç yönetimi, servis sorgulama, oturum analizi ve Local SYSTEM bağlamında Explorer başlatma gibi işlemleri güvenli bir akış içinde sunar.
Amaç ve Kullanım Senaryosu
Kurumsal ortamlarda Sysinternals araçları genellikle ayrı ayrı çalıştırılır.
Bu betik:
PSTools bileşenlerini otomatik tespit eder,
Ortak hata yönetimi sağlar,
Tek menüden operasyon yürütür,
PowerShell 5.1 ve 7.x ile uyumlu çalışır.
Özellikle aşağıdaki senaryolarda faydalıdır:
Yerel sistem analizi
Arıza giderme (troubleshooting)
Servis ve süreç denetimi
SYSTEM yetkisi gerektiren GUI testleri
Adli bilişim ve olay müdahalesi
PSTools Bileşen Mimarisi
Betik aşağıdaki Sysinternals araçlarını zorunlu kabul eder:
PsInfo.exe : Sistem donanım ve işletim sistemi bilgisi
PsList.exe : Çalışan süreçlerin listelenmesi
PsService.exe : Windows servis yönetimi
PsLoggedOn.exe : Oturum açmış kullanıcıların tespiti
PsExec.exe :Farklı güvenlik bağlamında süreç çalıştırma
PsKill.exe : Süreç sonlandırma
Arama Sırası
PATH ortam değişkeni : C:\PSTools ====================>>>Dizin mutlaka system/kullanıcı path değişkenine eklenmiş olmaldır.
Betiğin bulunduğu dizin : C:\PSTools ana dizini ...============>>> PSTools dizini mutlaka C: \ kök dizinde olmalıdır.
Bu yapı, betiğin taşınabilir (portable) çalışmasına olanak verir.
SONUÇ OLARAK :
Local_PSTools_Manager_v3.0.ps1, Sysinternals PSTools paketini modern PowerShell mühendislik prensipleriyle birleştiren, yerel Windows sistemleri için taşınabilir bir yönetim konsoludur.
Teknik olarak betik:
PSTools bileşenlerini otomatik keşfeder,
Merkezi hata yönetimi uygular,
Süreç ve servis analizini standartlaştırır,
Local SYSTEM bağlamında etkileşimli oturum oluşturabilir,
Kurumsal troubleshooting ve güvenlik operasyonları için uygun bir temel sunar.
En dikkat edilmesi gereken bölüm PsExec ile SYSTEM Explorer başlatma fonksiyonudur; bu özellik, betiği sıradan bir bilgi toplama aracından çıkarıp yüksek ayrıcalıklı sistem yönetim aracı kategorisine taşımaktadır.
BETİK İÇERİĞİ : ( Local_ PSTools_Manager_v3.0.ps1 )
Kod: Tümünü seç
#Requires -RunAsAdministrator
<#
.SYNOPSIS
Local PSTools management console for Windows systems.
.DESCRIPTION
This script provides a menu-driven management interface for Sysinternals PSTools.
It is compatible with Windows PowerShell 5.1 and PowerShell 7.x and follows
the TRWE_2012 PowerShell Engineering Standard.
.FEATURES
- System information (PsInfo)
- Running processes (PsList)
- Service status (PsService)
- Logged-on users (PsLoggedOn)
- Process termination (PsKill)
- Explorer launch as Local SYSTEM (PsExec)
- PSTools diagnostics
- Unified error handling
.NOTES
Version : 3.0
Standard : TRWE_2012
Encoding : UTF-8 with BOM
Language : British English
#>
Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
try {
[Console]::OutputEncoding = [System.Text.UTF8Encoding]::new()
} catch {
}
$script:PsTools = @{}
function Pause-Script {
Read-Host "`nPress ENTER to continue"
}
function Write-Section {
param([string]$Title)
Clear-Host
Write-Host ("=" * 60) -ForegroundColor Cyan
Write-Host $Title -ForegroundColor Cyan
Write-Host ("=" * 60) -ForegroundColor Cyan
Write-Host
}
function Resolve-PsTool {
param(
[Parameter(Mandatory = $true)]
[string]$Name
)
$candidates = @(
$Name,
(Join-Path $env:SystemDrive "PSTools\$Name"),
(Join-Path $PSScriptRoot $Name),
(Join-Path $PSScriptRoot "PSTools\$Name")
)
foreach ($candidate in $candidates) {
try {
$command = Get-Command $candidate -ErrorAction Stop
return $command.Source
} catch {
}
if (Test-Path $candidate) {
return (Resolve-Path $candidate).Path
}
}
return $null
}
function Initialise-PsTools {
$required = @(
'PsInfo.exe',
'PsList.exe',
'PsService.exe',
'PsLoggedOn.exe',
'PsExec.exe',
'PsKill.exe'
)
$missing = @()
foreach ($tool in $required) {
$resolvedPath = Resolve-PsTool -Name $tool
if ($resolvedPath) {
$script:PsTools[$tool] = $resolvedPath
} else {
$missing += $tool
}
}
if ($missing.Count -gt 0) {
Write-Host "Missing PSTools components:" -ForegroundColor Red
$missing | ForEach-Object { Write-Host " - $_" -ForegroundColor Red }
Write-Host "`nSearch locations:" -ForegroundColor Yellow
Write-Host " - PATH"
Write-Host " - $env:SystemDrive\PSTools"
Write-Host " - Script directory"
Write-Host " - Script\PSTools"
Pause-Script
return $false
}
Write-Host "All PSTools components were detected successfully." -ForegroundColor Green
return $true
}
function Invoke-PsTool {
param(
[Parameter(Mandatory = $true)]
[string]$Tool,
[string[]]$Arguments = @()
)
if (-not $script:PsTools.ContainsKey($Tool)) {
throw "PSTools component is not initialised: $Tool"
}
$exe = $script:PsTools[$Tool]
& $exe @Arguments
return $LASTEXITCODE
}
function Show-SystemInformation {
Write-Section "SYSTEM INFORMATION"
try {
& $script:PsTools['PsInfo.exe'] -accepteula | Out-Host
} catch {
Write-Host "PsInfo could not be executed." -ForegroundColor Red
Write-Host $_.Exception.Message -ForegroundColor DarkGray
}
Pause-Script
}
function Show-ProcessList {
Write-Section "RUNNING PROCESSES"
try {
$output = @(& $script:PsTools['PsList.exe'])
if ($output.Count -eq 0) {
Write-Host "No process information was returned." -ForegroundColor Yellow
} else {
$output | Select-Object -First 30 | Out-Host
if ($output.Count -gt 30) {
Write-Host
Write-Host ("Displaying first 30 entries of {0} total process lines." -f $output.Count) -ForegroundColor Yellow
}
}
} catch {
Write-Host "PsList could not be executed." -ForegroundColor Red
Write-Host $_.Exception.Message -ForegroundColor DarkGray
}
Pause-Script
}
function Show-ServiceStatus {
Write-Section "SERVICE STATUS"
try {
& $script:PsTools['PsService.exe'] query | Out-Host
} catch {
Write-Host "PsService could not be executed." -ForegroundColor Red
Write-Host $_.Exception.Message -ForegroundColor DarkGray
}
Pause-Script
}
function Show-LoggedOnUsers {
Write-Section "LOGGED-ON USERS"
try {
& $script:PsTools['PsLoggedOn.exe'] -l | Out-Host
} catch {
Write-Host "PsLoggedOn could not be executed." -ForegroundColor Red
Write-Host $_.Exception.Message -ForegroundColor DarkGray
}
Pause-Script
}
function Stop-ProcessInteractive {
Write-Section "TERMINATE PROCESS"
$processName = Read-Host "Enter process name (for example: notepad.exe)"
if ([string]::IsNullOrWhiteSpace($processName)) {
Write-Host "No process name was provided." -ForegroundColor Yellow
Start-Sleep -Seconds 2
return
}
if ($processName -notmatch '\.exe$') {
$processName = "$processName.exe"
}
try {
$exitCode = Invoke-PsTool -Tool 'PsKill.exe' -Arguments @(
'-accepteula',
$processName
)
if ($exitCode -eq 0) {
Write-Host "Process terminated successfully: $processName" -ForegroundColor Green
} else {
Write-Host "PsKill returned exit code $exitCode." -ForegroundColor Yellow
}
} catch {
Write-Host "Failed to terminate process." -ForegroundColor Red
Write-Host $_.Exception.Message -ForegroundColor DarkGray
}
Pause-Script
}
function Start-SystemExplorer {
Write-Section "START EXPLORER AS LOCAL SYSTEM"
Write-Host "This operation will launch a new Explorer instance with Local SYSTEM privileges." -ForegroundColor Yellow
Write-Host "The current Explorer shell will be restarted in a controlled manner." -ForegroundColor Yellow
Write-Host
$confirmation = Read-Host "Type YES to continue"
if ($confirmation -ne 'YES') {
Write-Host "Operation cancelled." -ForegroundColor Yellow
Start-Sleep -Seconds 2
return
}
try {
$temporaryExplorer = Start-Process -FilePath explorer.exe -PassThru -WindowStyle Hidden
Start-Sleep -Seconds 2
Get-Process -Name explorer -ErrorAction SilentlyContinue |
Where-Object { $_.Id -ne $temporaryExplorer.Id } |
Stop-Process -Force -ErrorAction SilentlyContinue
Start-Sleep -Seconds 2
& $script:PsTools['PsExec.exe'] -accepteula -s -i explorer.exe | Out-Null
Write-Host "SYSTEM Explorer launch request completed." -ForegroundColor Green
Write-Host "Verify the new Explorer session before closing this console." -ForegroundColor Green
} catch {
Write-Host "Failed to launch SYSTEM Explorer." -ForegroundColor Red
Write-Host $_.Exception.Message -ForegroundColor DarkGray
}
Pause-Script
}
function Show-PsToolsDiagnostics {
Write-Section "PSTOOLS DIAGNOSTICS"
$required = @(
'PsInfo.exe',
'PsList.exe',
'PsService.exe',
'PsLoggedOn.exe',
'PsExec.exe',
'PsKill.exe'
)
foreach ($tool in $required) {
$path = Resolve-PsTool -Name $tool
if ($path) {
Write-Host ("[FOUND] {0}" -f $tool) -ForegroundColor Green
Write-Host (" {0}" -f $path) -ForegroundColor DarkGray
} else {
Write-Host ("[MISSING] {0}" -f $tool) -ForegroundColor Red
}
Write-Host
}
Pause-Script
}
function Show-Menu {
Clear-Host
Write-Host "LOCAL PSTOOLS MANAGER v3.0" -ForegroundColor Cyan
Write-Host "TRWE_2012 STANDARD EDITION" -ForegroundColor Cyan
Write-Host ("=" * 60) -ForegroundColor Cyan
Write-Host
Write-Host " 1. Show system information"
Write-Host " 2. Show running processes"
Write-Host " 3. Show service status"
Write-Host " 4. Show logged-on users"
Write-Host " 5. Terminate a process"
Write-Host " 6. Start Explorer as Local SYSTEM"
Write-Host " 7. PSTools diagnostics"
Write-Host " 8. Exit"
Write-Host
}
if (-not (Initialise-PsTools)) {
exit 1
}
Pause-Script
do {
Show-Menu
$selection = Read-Host "Select an option"
switch ($selection) {
'1' { Show-SystemInformation }
'2' { Show-ProcessList }
'3' { Show-ServiceStatus }
'4' { Show-LoggedOnUsers }
'5' { Stop-ProcessInteractive }
'6' { Start-SystemExplorer }
'7' { Show-PsToolsDiagnostics }
'8' {
Write-Host "Exiting..." -ForegroundColor Cyan
break
}
default {
Write-Host "Invalid selection." -ForegroundColor Yellow
Start-Sleep -Seconds 1
}
}
} while ($selection -ne '8')
Read-Host "`nPress ENTER to exit."


Local SYSTEM Olarak Explorer Başlatma
Bu bölüm betiğin en kritik ve en yüksek ayrıcalıklı operasyonudur.
Algoritmatik İş Akışı
Kod: Tümünü seç
Kullanıcı Onayı
↓
Geçici Explorer Başlat
↓
Mevcut Explorer Süreçlerini Sonlandır
↓
PsExec ile SYSTEM Explorer Başlat
↓
Yeni Oturumu DoğrulaBu, aşağıdaki testler için kullanılır:
SYSTEM erişim doğrulaması
Korunan kayıt defteri anahtarları
TrustedInstaller öncesi analiz
GUI tabanlı güvenlik araştırmaları
SYSTEM Explorer
Bu işlem:
Tam sistem yetkisi sağlar,
Kullanıcı izolasyonunu aşabilir,
Yanlış kullanımda güvenlik politikasını ihlal edebilir.
Microsoft PSTools İndirme : https://learn.microsoft.com/en-us/sysin ... ds/pstools
Güle güle kullanın...


