Windows Sisteminde "Yüklü PowerShell" Sürümleri Bulan/Gösteren PS1 Betiği

Programlama ve Script dilleri konusunda bilgi paylaşım alanıdır.
Cevapla
Kullanıcı avatarı
TRWE_2012
Zettabyte1
Zettabyte1
Mesajlar: 15567
Kayıt: 25 Eyl 2013, 13:38
cinsiyet: Erkek
Teşekkür etti: 2698 kez
Teşekkür edildi: 5598 kez

Windows Sisteminde "Yüklü PowerShell" Sürümleri Bulan/Gösteren PS1 Betiği

Mesaj gönderen TRWE_2012 »

Merhabalar

PowerShellSürüKonrol.ps1

Kod: Tümünü seç

<#
    PowerShell Version Checker
    Detects Windows PowerShell (current console) and PowerShell 7 (Core) versions.
#>

Write-Host "=== Installed PowerShell Versions ===" -ForegroundColor Cyan

# 1. CURRENT CONSOLE INFORMATION
$ps1Version = $PSVersionTable.PSVersion.ToString()
$ps1Edition = $PSVersionTable.PSEdition
$ps1DotNet = [System.Environment]::Version.ToString()
if ([System.Environment]::Is64BitProcess) { $ps1Arch = "64-Bit" } else { $ps1Arch = "32-Bit" }

# 2. RETRIEVE POWERSHELL 7 (Core) INFORMATION
$ps7Version = "Not Installed"
$ps7Edition = "-"
$ps7DotNet = "-"
$ps7Arch = "-"
$ps7Path = "-"
$ps7Status = "Not Found"

$pwshCmd = Get-Command pwsh -ErrorAction SilentlyContinue

if ($pwshCmd) {
    $ps7Path = $pwshCmd.Source
    $ps7Status = "Installed and Found"

    # Inner command as plain text (kept simple: no nested quoting inside the pipe-delimited output)
    $ps7Command = '$PSVersionTable.PSVersion.ToString() + "|" + $PSVersionTable.PSEdition.ToString() + "|" + [System.Environment]::Version.ToString() + "|" + ([System.Environment]::Is64BitProcess)'

    # Encode the command to completely avoid quoting/escaping issues when passed to pwsh.exe
    $encodedBytes = [System.Text.Encoding]::Unicode.GetBytes($ps7Command)
    $encodedCommand = [Convert]::ToBase64String($encodedBytes)

    # Call pwsh via its full resolved path, using -EncodedCommand
    $ps7Output = & $ps7Path -NoProfile -EncodedCommand $encodedCommand 2>$null

    if ($ps7Output) {
        $parts = $ps7Output -split '\|'
        if ($parts.Count -ge 4) {
            $ps7Version = $parts[0]
            $ps7Edition = $parts[1]
            $ps7DotNet = $parts[2]
            if ($parts[3] -match "True") { $ps7Arch = "64-Bit" } else { $ps7Arch = "32-Bit" }
        }
        else {
            $ps7Status = "Found but output could not be parsed"
        }
    }
    else {
        $ps7Status = "Found but did not respond"
    }
}

# DISPLAY RESULTS
Write-Host "`n[1] Windows PowerShell (Current Console)" -ForegroundColor Yellow
Write-Host "----------------------------------------"
Write-Host "Version      : $ps1Version"
Write-Host "Edition      : $ps1Edition"
Write-Host ".NET         : $ps1DotNet"
Write-Host "Architecture : $ps1Arch"

Write-Host "`n[2] PowerShell 7 (Core)" -ForegroundColor Yellow
Write-Host "----------------------------------------"
Write-Host "Status       : $ps7Status"
Write-Host "Version      : $ps7Version"
Write-Host "Edition      : $ps7Edition"
Write-Host ".NET         : $ps7DotNet"
Write-Host "Architecture : $ps7Arch"
Write-Host "Path         : $ps7Path"
Write-Host "========================================`n"

# BUILD REPORT TEXT
$report = "=== PowerShell Version Report ===`n"
$report += "`n[1] Windows PowerShell (Current Console)`n"
$report += "Version      : $ps1Version`n"
$report += "Edition      : $ps1Edition`n"
$report += ".NET         : $ps1DotNet`n"
$report += "Architecture : $ps1Arch`n"
$report += "`n[2] PowerShell 7 (Core)`n"
$report += "Status       : $ps7Status`n"
$report += "Version      : $ps7Version`n"
$report += "Edition      : $ps7Edition`n"
$report += ".NET         : $ps7DotNet`n"
$report += "Architecture : $ps7Arch`n"
$report += "Path         : $ps7Path`n"

# COPY REPORT TO CLIPBOARD (wrapped: clipboard access can fail depending on session type)
try {
    Set-Clipboard -Value $report
    Write-Host "[+] All information has been copied to the clipboard." -ForegroundColor Green
}
catch {
    Write-Host "[!] Could not copy to clipboard: $($_.Exception.Message)" -ForegroundColor Red
}

Read-Host "`nPress ENTER to exit."
Ekran Görüntüsü :
Resim
Gördüğünüz gibi bende iki sürüm yüklü..Bunlardan biri temiz kurulumla gelen, diğeri ise sonra'dan kurulan...
Kullanıcı avatarı
burak35
Zettabyte4
Zettabyte4
Mesajlar: 18103
Kayıt: 07 Eki 2016, 13:06
cinsiyet: Erkek
Teşekkür etti: 10513 kez
Teşekkür edildi: 12293 kez

Re: Windows Sisteminde "Yüklü PowerShell" Sürümleri Bulan/Gösteren PS1 Betiği

Mesaj gönderen burak35 »

Hiç sevmedim şu powershelli. süt oğlan hesabı.
Cevapla

“Programlama ve Script dilleri” sayfasına dön