UWF_RegistryFilter

Menambahkan atau menghapus pengecualian registri dari pemfilteran Filter Tulis Terpadu (UWF), dan juga melakukan perubahan registri.

Sintaks

class UWF_RegistryFilter{
    [key, Read] boolean CurrentSession;
    [Read, Write] boolean PersistDomainSecretKey;
    [Read, Write] boolean PersistTSCAL;

    UInt32 AddExclusion(
        string RegistryKey
    );
    UInt32 RemoveExclusion(
        string RegistryKey
    );
    UInt32 FindExclusion(
        [in] string RegistryKey,
        [out] boolean bFound
    );
    UInt32 GetExclusions(
        [out, EmbeddedInstance("UWF_ExcludedRegistryKey")] string ExcludedKeys[]
    );
    UInt32 CommitRegistry(
        [in] string RegistryKey,
        [in] string ValueName
    );
    UInt32 CommitRegistryDeletion(
        string Registrykey,
        string ValueName
    );
};

Anggota

Tabel berikut mencantumkan metode dan properti yang termasuk dalam kelas ini.

Metode Deskripsi
UWF_RegistryFilter.AddExclusion Menambahkan kunci registri ke daftar pengecualian registri untuk UWF.
UWF_RegistryFilter.CommitRegistry Menerapkan perubahan pada kunci dan nilai registri yang ditentukan.
UWF_RegistryFilter.CommitRegistryDeletion Menghapus kunci registri atau nilai registri yang ditentukan dan melakukan penghapusan.
UWF_RegistryFilter.FindExclusion Menentukan apakah kunci registri tertentu dikecualikan agar tidak difilter oleh UWF.
UWF_RegistryFilter.GetExclusions Mengambil semua pengecualian kunci registri dari sistem yang dilindungi oleh UWF
UWF_RegistryFilter.RemoveExclusion Menghapus kunci registri dari daftar pengecualian registri untuk Filter Tulis Terpadu (UWF).

Properti

Properti Jenis Data Kualifikasi Deskripsi
CurrentSession Boolean [kunci, baca] Menunjukkan sesi mana objek berisi pengaturan.
- Benar jika pengaturan adalah untuk sesi
- saat ini False jika pengaturan adalah untuk sesi berikutnya yang mengikuti mulai ulang.
PersistDomainSecretKey Boolean [baca, tulis] Menunjukkan apakah kunci registri rahasia domain ada dalam daftar pengecualian registri. Jika kunci registri tidak ada dalam daftar pengecualian, perubahan tidak akan dipertahankan setelah menghidupkan ulang.
- Benar untuk disertakan dalam daftar
pengecualian - Jika tidak Salah.
PersistTSCAL Boolean [baca, tulis] Menunjukkan apakah kunci registri Terminal Server Client Access License (TSCAL) berada dalam daftar pengecualian registri UWF. Jika kunci registri tidak ada dalam daftar pengecualian, perubahan tidak akan dipertahankan setelah menghidupkan ulang.
- True untuk disertakan dalam daftar
pengecualian- Jika tidak, atur ke False

Keterangan

Penambahan atau penghapusan pengecualian registri, termasuk perubahan pada nilai PersistDomainSecretKey dan PersistTSCAL, berlaku setelah restart berikutnya di mana UWF diaktifkan.

Anda hanya dapat menambahkan kunci registri di akar registri HKLM ke daftar pengecualian registri UWF.

Anda juga dapat menggunakan UWF_RegistryFilter untuk mengecualikan kunci registri rahasia domain dan kunci registri TSCAL dari pemfilteran UWF.

Contoh

Contoh berikut menunjukkan cara mengelola pengecualian registri UWF dengan menggunakan penyedia Windows Management Instrumentation (WMI) dalam skrip PowerShell.

Skrip PowerShell membuat empat fungsi, lalu menunjukkan cara menggunakannya.

Fungsi pertama, Get-RegistryExclusions, menampilkan daftar pengecualian registri UWF untuk sesi saat ini dan sesi berikutnya yang mengikuti mulai ulang.

Fungsi kedua, Add-RegistryExclusion, menambahkan entri registri ke daftar pengecualian registri UWF setelah Anda memulai ulang perangkat.

Fungsi ketiga, Remove-RegistryExclusion, menghapus entri registri dari daftar pengecualian UWF setelah Anda memulai ulang perangkat.

Fungsi keempat, Clear-RegistryExclusions, menghapus semua pengecualian registri UWF. Anda harus memulai ulang perangkat sebelum UWF berhenti memfilter pengecualian.

$COMPUTER = "EMBEDDEDDEVICE"
$NAMESPACE = "root\standardcimv2\embedded"

# Define common parameters

$CommonParams = @{"namespace"=$NAMESPACE; "computer"=$COMPUTER}

function Get-RegistryExclusions() {

# This function lists the UWF registry exclusions, both
# for the current session as well as the next session after a restart.


# Get the UWF_RegistryFilter configuration for the current session

    $currentConfig = Get-WMIObject -class UWF_RegistryFilter @CommonParams |
        where {
            $_.CurrentSession -eq $true
        };

# Get the UWF_RegistryFilter configuration for the next session after a restart

    $nextConfig = Get-WMIObject -class UWF_RegistryFilter @CommonParams |
        where {
            $_.CurrentSession -eq $false
        };

# Display registry exclusions for the current session

    if ($currentConfig) {

        Write-Host ""
        Write-Host "The following registry entries are currently excluded from UWF filtering:";

        $currentExcludedList = $currentConfig.GetExclusions()

        if ($currentExcludedList.ExcludedKeys) {
            foreach ($registryExclusion in $currentExcludedList.ExcludedKeys)  {
                Write-Host "  " $registryExclusion.RegistryKey
            }
        } else {
            Write-Host "  None"
        }
    } else {
        Write-Error "Could not retrieve UWF_RegistryFilter.";
}

# Display registry exclusions for the next session after a restart

    if ($nextConfig) {

        Write-Host ""
        Write-Host "The following registry entries will be excluded from UWF filtering after the next restart:";

        $nextExcludedList = $nextConfig.GetExclusions()

        if ($nextExcludedList.ExcludedKeys) {
            foreach ($registryExclusion in $nextExcludedList.ExcludedKeys)  {
                Write-Host "  " $registryExclusion.RegistryKey
            }
        } else {
            Write-Host "  None"
        }
        Write-Host ""
    }
}

function Add-RegistryExclusion($exclusion) {

# This function adds a new UWF registry exclusion.
# The new registry exclusion takes effect the next time the device is restarted and UWF is enabled.

# $exclusion is the path of the registry exclusion

# Get the UWF_RegistryFilter configuration for the next session after a restart

    $nextConfig = Get-WMIObject -class UWF_RegistryFilter @CommonParams |
        where {
            $_.CurrentSession -eq $false
        };

# Add the exclusion

    if ($nextConfig) {
        $nextConfig.AddExclusion($exclusion) | Out-Null;
        Write-Host "Added exclusion $exclusion.";
    } else {
        Write-Error "Could not retrieve UWF_RegistryFilter";
    }
}

function Remove-RegistryExclusion($exclusion) {

# This function removes a UWF registry exclusion.
# The registry exclusion is removed the next time the device is restarted

# $exclusion is the path of the registry exclusion

# Get the UWF_RegistryFilter configuration for the next session after a restart

    $nextConfig = Get-WMIObject -class UWF_RegistryFilter @CommonParams |
        where {
            $_.CurrentSession -eq $false
        };

# Try to remove the exclusion

    if ($nextConfig) {
        try {
            $nextConfig.RemoveExclusion($exclusion) | Out-Null;
            Write-Host "Removed exclusion $exclusion.";
        } catch {
            Write-Host "Could not remove exclusion $exclusion."
        }
    } else {
        Write-Error "Could not retrieve UWF_RegistryFilter";
    }
}

function Clear-RegistryExclusions() {

# This function removes all UWF registry exclusions
# The registry exclusions are removed the next time the device is restarted

# Get the configuration for the next session

    $nextConfig = Get-WMIObject -class UWF_RegistryFilter @CommonParams |
        where {
            $_.CurrentSession -eq $false
        };

# Remove all registry exclusions

    if ($nextConfig) {

        Write-Host "Removing all registry exclusions:";

        $nextExcludedList = $nextConfig.GetExclusions()

        if ($nextExcludedList) {
            foreach ($registryExclusion in $nextExcludedList.ExcludedKeys)  {
                Write-Host "Removing:" $registryExclusion.RegistryKey
                $nextConfig.RemoveExclusion($registryExclusion.RegistryKey) | Out-Null
            }
        } else {
            Write-Host "No registry exclusions to remove."
        }
        Write-Host ""
    }
}

# Some examples of using the functions

Clear-RegistryExclusions

Get-RegistryExclusions

Add-RegistryExclusion "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer"
Add-RegistryExclusion "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\DateTime\Servers\(Default)"

Get-RegistryExclusions

Remove-RegistryExclusion "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer"

Get-RegistryExclusions

Clear-RegistryExclusions

Persyaratan

Edisi Windows Didukung
Windows Home Tidak
Windows Pro Tidak
Windows Enterprise Ya
Windows Education Ya
Windows IoT Enterprise Ya