Bu örnek betiği kopyalayıp yapıştırın ve ortamınız için gerektiği gibi değiştirin:

<# . ÖZET     Güvenli Önyükleme Güncelleştirmesi zamanlanmış görevini etkinleştirir.

.DESCRIPTION     Bu betik, Windows Güvenli Önyükleme Güncelleştirmesi zamanlanmış görevini güvence altına alır     (\Microsoft\Windows\PI\Secure-Boot-Update) etkin. Devre dışı bırakılırsa,     bunu etkinleştirir. Görev silinmişse yeniden oluşturabilir.

.PARAMETER Action     Gerçekleştirilecek eylem. Geçerli değerler: denetleme, etkinleştirme, oluşturma     - denetim: Yalnızca görev durumunu denetleyin     - enable: (default) Devre dışı bırakılırsa görevi etkinleştirin. Görev eksikse, oluşturulması istenir.- create: Mevcut değilse görevi oluşturun

.PARAMETER ComputerName     Isteğe bağlı. Görevi denetlemek/etkinleştirmek için bilgisayar adları dizisi.Belirtilmezse, yerel makinede çalışır.

.PARAMETER Credential     Isteğe bağlı. Uzak bilgisayar erişimi için kimlik bilgileri.

.PARAMETER Quiet     İstemleri bastırır ve otomatik olarak Evet'i yanıtlar. Otomasyon için kullanışlıdır.

.EXAMPLE     .\Enable-SecureBootTask.ps1     # Yerel makinede görev durumunu etkinleştirir

.EXAMPLE     .\Check-SecureBootScheduledTask.ps1 etkinleştir     # Devre dışı bırakılırsa görevi etkinleştirir. Eksikse oluşturmak için İstemler.

.EXAMPLE     .\Check-SecureBootScheduledTask.ps1 oluşturma     # Silinmişse görevi oluşturur, ardından durumunu denetler

.EXAMPLE     .\Check-SecureBootScheduledTask.ps1 denetimi -ComputerName "PC1", "PC2"     # Uzak makinelerde görevi denetler

.NOTES     Görevi etkinleştirmek veya oluşturmak için yönetici ayrıcalıkları gerektirir.Görev Yolu: \Microsoft\Windows\PI\Secure-Boot-Update     Görev, yükseltilmiş ayrıcalıklarla 12 saatte bir taskhostw.exe çalışır.#>

[CmdletBinding(SupportsShouldProcess)] param(     [Parameter(Position=0)]     [ValidateSet('check', 'enable', 'create', '')]     [string]$Action = 'enable',

    [Parameter()]     [string[]]$ComputerName,

    [Parameter()]     [PSCredential]$Credential,

    [Parameter()]     [Alias('Force', 'Silent')]     [switch]$Quiet )

# Convert Action to switches for backward compatibility $Enable = $Action -eq 'enable' $Create = $Action -eq 'create'

# Download URL: https://aka.ms/getsecureboot -> "Deployment and Monitoring Samples" # Not: Bu betik, Güvenli Önyükleme Güncelleştirmesi görevini etkinleştirmek için uç noktalarda çalışır.

$TaskPath = "\Microsoft\Windows\PI\" $TaskName = "Secure-Boot-Update"

function Get-SecureBootTaskStatus {     [CmdletBinding()]     param(         [string]$Computer = $env:COMPUTERNAME     )

    $result = [PSCustomObject]@{         ComputerName = $Computer         TaskExists = $false         TaskState = $null         IsEnabled = $false         LastRunTime = $null         NextRunTime = $null         Hata = $null     }

    try {         if ($Computer -eq $env:COMPUTERNAME -veya $Computer -eq "localhost" -veya $Computer -eq ".") {             # Daha güvenilir görev algılama için schtasks.exe kullanın             $schtasksOutput = schtasks.exe /Query /TN "$TaskPath$TaskName" /FO CSV 2>&1                          if ($LASTEXITCODE -ne 0) {                 # Görev bulunamadı hatası değil - yalnızca görevin mevcut olmadığı anlamına gelir                 $result. TaskExists = $false                 return $result             }                          # CSV çıkışını ayrıştır             $taskData = $schtasksOutput | ConvertFrom-Csv             if ($taskData) {                 $result. TaskExists = $true                 $result. TaskState = $taskData.Status                 $result. IsEnabled = ($taskData.Status -eq 'Ready' -veya $taskData.Status -eq 'Running')                                  # Verilerden sonraki çalışma zamanını almayı deneyin                 if ($taskData.'Sonraki Çalışma Zamanı' -ve $taskData.'Sonraki Çalışma Zamanı' -ne 'YOK') {                     try {                         $result. NextRunTime = [DateTime]::P arse($taskData.'Sonraki Çalışma Zamanı')                     } catch { }                 }             }         }         else {             # Uzak bilgisayar - schtasks ile Invoke-Command kullanın             $remoteResult = Invoke-Command -ComputerName $Computer -ScriptBlock {                 param($fullTaskName)                 $output = schtasks.exe /Query /TN $fullTaskName /FO CSV 2>&1                 @{                     ExitCode = $LASTEXITCODE                     Çıkış = $output                 }             } -ArgumentList "$TaskPath$TaskName" -ErrorAction Stop

            if ($remoteResult.ExitCode -ne 0) {                 # Görev bulunamadı hatası değil - yalnızca görevin mevcut olmadığı anlamına gelir                 $result. TaskExists = $false                 return $result             }

            $taskData = $remoteResult.Output | ConvertFrom-Csv             if ($taskData) {                 $result. TaskExists = $true                 $result. TaskState = $taskData.Status                 $result. IsEnabled = ($taskData.Status -eq 'Ready' -veya $taskData.Status -eq 'Running')             }         }     }     catch {         $result. Hata = $_. Exception     }

    return $result }

function New-SecureBootTask {     [CmdletBinding(SupportsShouldProcess)]     param(         [string]$Computer = $env:COMPUTERNAME     )

    $success = $false     $errorMsg = $null

    # Task definition - matches the original Windows Secure Boot Update task     # SBServicing sınıfıyla ComHandler kullanır, LocalSystem olarak çalışır     $taskXml = @" <?xml version="1.0" encoding="UTF-16"?> <Görev sürümü="1.6" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">   <RegistrationInfo>     <Tarih>2012-02-07T16:39:20</Tarih>     <SecurityDescriptor>O:BAG:BAD:P(A;; FA;;; BA)(A;; FA;;; SY)(A;; FRFX;;; LS)</SecurityDescriptor>     '$(@%SystemRoot%\system32\TpmTasks.dll,-601)<Kaynak>/Source><     <Yazar>'$(@%SystemRoot%\system32\TpmTasks.dll,-600)</Author>     <Açıklama>'$(@%SystemRoot%\system32\TpmTasks.dll,-604)</Description>     <URI>\Microsoft\Windows\PI\Secure-Boot-Update</URI>   </RegistrationInfo>   <Sorumluları>     <Principal id="LocalSystem">       <UserId>S-1-5-18</UserId>     </Principal>   </Principals>   <Ayarları>     <DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>     ><0 StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>     ><4 ExecutionTimeLimit>PT1H</ExecutionTimeLimit>     ><8 MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>     <StartWhenAvailable>true</StartWhenAvailable>     IdleSettings><       <StopOnIdleEnd>true</StopOnIdleEnd>       <RestartOnIdle>false</RestartOnIdle>     </IdleSettings>     <UseUnifiedSchedulingEngine>true</UseUnifiedSchedulingEngine>   </Ayarlar>   <Tetikleyicileri>     BootTrigger><       PT5M</Delay>>< Gecikme       <Yineleme>         <Aralık>PT12H</Interval>       </Yineleme>     /BootTrigger><   </Triggers>   <Actions Context="LocalSystem">     comhandler><       <ClassId>{5014B7C8-934E-4262-9816-887FA745A6C4}</ClassId>       <Veri><! [CDATA[SBServicing]]></Data>     </ComHandler>   </Actions> </Görev> " @

    try {         if ($Computer -eq $env:COMPUTERNAME -veya $Computer -eq "localhost" -veya $Computer -eq ".") {             if ($PSCmdlet.ShouldProcess("$TaskPath$TaskName", "Zamanlanmış görev oluştur")) {                 # XML'yi geçici dosyaya kaydetme ve içeri aktarma                 $tempFile = [System.IO.Path]::GetTempFileName()                 $taskXml | Out-File -FilePath $tempFile -Kodlama Unicode -Force                                  $output = schtasks.exe /Create /TN "$TaskPath$TaskName" /XML $tempFile /F 2>&1                                  Remove-Item $tempFile -Force -ErrorAction SilentlyContinue                                  if ($LASTEXITCODE -eq 0) {                     $success = $true                 } else {                     $errorMsg = $output -join " "                 }             }         }         else {             if ($PSCmdlet.ShouldProcess("$Computer\$TaskPath$TaskName", "Zamanlanmış görev oluştur")) {                 $result = Invoke-Command -ComputerName $Computer -ScriptBlock {                     param($taskPath, $taskName, $xml)                     $tempFile = [System.IO.Path]::GetTempFileName()                     $xml | Out-File -FilePath $tempFile -Kodlama Unicode -Force                     $output = schtasks.exe /Create /TN "$taskPath$taskName" /XML $tempFile /F 2>&1                     Remove-Item $tempFile -Force -ErrorAction SilentlyContinue                     @{ ExitCode = $LASTEXITCODE; Çıkış = $output }                 } -ArgumentList $TaskPath, $TaskName, $taskXml -ErrorAction Stop                                  if ($result. ExitCode -eq 0) {                     $success = $true                 } else {                     $errorMsg = $result. Output -join " "                 }             }         }     }     catch {         $errorMsg = $_. Exception     }

    return @{         Başarı = $success         Hata = $errorMsg     } }

function Enable-SecureBootTask {     [CmdletBinding(SupportsShouldProcess)]     param(         [string]$Computer = $env:COMPUTERNAME     )

    $success = $false     $errorMsg = $null

    try {         if ($Computer -eq $env:COMPUTERNAME -veya $Computer -eq "localhost" -veya $Computer -eq ".") {             if ($PSCmdlet.ShouldProcess("$TaskPath$TaskName", "Zamanlanmış görevi etkinleştir")) {                 $output = schtasks.exe /Change /TN "$TaskPath$TaskName" /ENABLE 2>&1                 if ($LASTEXITCODE -eq 0) {                     $success = $true                 } else {                     $errorMsg = $output -join " "                 }             }         }         else {             if ($PSCmdlet.ShouldProcess("$Computer\$TaskPath$TaskName", "Zamanlanmış görevi etkinleştir")) {                 $result = Invoke-Command -ComputerName $Computer -ScriptBlock {                     param($fullTaskName)                     $output = schtasks.exe /Change /TN $fullTaskName /ENABLE 2>&1                     @{ ExitCode = $LASTEXITCODE; Çıkış = $output }                 } -ArgumentList "$TaskPath$TaskName" -ErrorAction Stop                                  if ($result. ExitCode -eq 0) {                     $success = $true                 } else {                     $errorMsg = $result. Output -join " "                 }             }         }     }     catch {         $errorMsg = $_. Exception     }

    return @{         Başarı = $success         Hata = $errorMsg     } }

# Main execution "" Write-Host Write-Host "========================================" -ForegroundColor Cyan Write-Host " Güvenli Önyükleme Güncelleştirme Görev Etkinleştiricisi" -ForegroundColor Cyan Write-Host "========================================" -ForegroundColor Cyan "" Write-Host Write-Host "Görev: $TaskPath$TaskName" -ForegroundColor Gray Write-Host ""

# Determine target computers $targets = if ($ComputerName) { $ComputerName } else { @($env:COMPUTERNAME) }

$results = @()

foreach ($computer in $targets) {     Write-Host "Denetim: $computer" -ForegroundColor Yellow     $status = Get-SecureBootTaskStatus -Bilgisayar $computer     if ($status. Hata) {         Write-Host " Hata: $($status. Hata)" -ForegroundColor Red     }     elseif (-değil $status. TaskExists) {         Write-Host " Görev bu sistemde yok" -ForegroundColor Red         # İstenirse oluştur veya Etkinleştir belirtildi mi sor         $shouldCreate = $Create         if (-not $shouldCreate -and $Enable) {             "" Write-Host             Write-Host " Görev silinmiş olabilir." -ForegroundColor Yellow             if ($Quiet) {                 Write-Host " Otomatik oluşturma görevi (Sessiz mod)" -ForegroundColor Cyan                 $shouldCreate = $true             } else {                 $confirm = Read-Host " Görevi yeniden oluşturmak istiyor musunuz?                    (Y/N)"                 if ($confirm -eq 'Y' -veya $confirm -eq 'y') {                     $shouldCreate = $true                 }             }         }                  if ($shouldCreate) {             Write-Host " Görev oluşturuluyor..." -ForegroundColor Yellow             $createResult = New-SecureBootTask -Bilgisayar $computer                          if ($createResult.Success) {                 Write-Host " Görev başarıyla oluşturuldu" -ForegroundColor Green                 # Durumu yeniden denetle                 $status = Get-SecureBootTaskStatus -Bilgisayar $computer                                  if ($status. TaskExists) {                     $stateColor = if ($status. IsEnabled) { "Green" } else { "Red" }                     Write-Host " Durum: $($status. TaskState)" -ForegroundColor $stateColor                 }             }             else {                 Write-Host " Oluşturulamadı: $($createResult.Error)" -ForegroundColor Red             }         }     }     else {         $stateColor = if ($status. IsEnabled) { "Green" } else { "Red" }         Write-Host " Durum: $($status. TaskState)" -ForegroundColor $stateColor                  if ($status. LastRunTime ve $status. LastRunTime -ne [DateTime]::MinValue) {             Write-Host " Son Çalıştırma: $($status. LastRunTime)" -ForegroundColor Gray         }         if ($status. NextRunTime ve $status. NextRunTime -ne [DateTime]::MinValue) {             Write-Host " Sonraki Çalıştırma: $($status. NextRunTime)" -ForegroundColor Gray         }

        # Enable if requested and currently disabled         if ($Enable -and -not $status. IsEnabled) {             Write-Host " Görevi etkinleştiriyor..." -ForegroundColor Yellow             $enableResult = Enable-SecureBootTask -Computer $computer             if ($enableResult.Success) {                 Write-Host " Görev başarıyla etkinleştirildi" -ForegroundColor Green                 # Durumu yeniden denetle                 $status = Get-SecureBootTaskStatus -Bilgisayar $computer             }             else {                 Write-Host " Etkinleştiremedi: $($enableResult.Error)" -ForegroundColor Red             }         }         elseif ($Enable -ve $status. IsEnabled) {             Write-Host " Görev zaten etkin" -ForegroundColor Green         }     }     $results += $status     Write-Host "" }                  

# Summary Write-Host "========================================" -ForegroundColor Cyan Write-Host " Summary" -ForegroundColor Cyan Write-Host "========================================" -ForegroundColor Cyan

$enabled = ($results | Where-Object { $_.IsEnabled }).Count $disabled = ($results | Where-Object { $_. TaskExists -ve -not $_. IsEnabled }). Sayısı $notFound = ($results | Where-Object { -not $_. TaskExists }). Sayısı $errors = ($results | Where-Object { $_. Hata }). Sayısı

Write-Host "Total Checked: $($results.Count)" Write-Host "Etkin: $enabled" -ForegroundColor Green if ($disabled -gt 0) { Write-Host "Disabled: $disabled" -ForegroundColor Red } if ($notFound -gt 0) { Write-Host "Bulunamadı: $notFound" -ForegroundColor Yellow } if ($errors -gt 0) { Write-Host "Hatalar: $errors" -ForegroundColor Red }

# Return results for pipeline $results  

Daha fazla yardıma mı ihtiyacınız var?

Daha fazla seçenek mi istiyorsunuz?

Abonelik avantajlarını keşfedin, eğitim kurslarına göz atın, cihazınızın güvenliğini nasıl sağlayacağınızı öğrenin ve daha fazlasını yapın.