Merhabalar,
ilgili code ile registery.pol dosyasının mevcut durumuna göre kontrol edilerek silinmesi sağlayabilirsiniz.
<#
##########################################################
#Script Title: RemoveRegisteryPol.ps1
#Script Description: it is used to delete registery.pol file
#Author: Selçuk Ergül
#Date Created: 06/10/2020
#Version: V1.0 - First relase.
#>
$path = "C:\Windows\System32\GroupPolicy\Machine\Registry.pol"
$Label = Get-Childitem $path
#$Actions = @('{00000000-0000-0000-0000-000000000108}','{00000000-0000-0000-0000-000000000113}')
if(Test-Path -Path $path)
{
if($Label.LastWriteTime -lt (Get-Date).AddDays(-1))
{
Remove-Item $path
if($?){Write-Output " ilgili $Label dosyasi $env:COMPUTERNAME alandan silindi."}
else{Write-Output "ilgili $Label dosyasi $env:COMPUTERNAME alandan silinemedi."}
#foreach ($Action in $Actions){
Invoke-WmiMethod -computername $env:COMPUTERNAME -Namespace ROOT\ccm -Class SMS_Client -Name TriggerSchedule -argumentList '{00000000-0000-0000-0000-000000000113}' | Out-File c:\temp\$env:COMPUTERNAME-Trigger.txt
if($?){Write-Output " Sccm Update Scan Cycle Tetiklenmistir."}
else{Write-Output " Sccm Update Scan Cycle Tetiklenememistir."}
#}
}
else
{
Invoke-WmiMethod -computername $env:COMPUTERNAME -Namespace ROOT\ccm -Class SMS_Client -Name TriggerSchedule -argumentList '{00000000-0000-0000-0000-000000000113}' | Out-File c:\temp\$env:COMPUTERNAME-Trigger.txt
if($?){Write-Output " $env:COMPUTERNAME Registery.pol dosyasi guncel ve Update Scan Cycle Tetiklenmistir."}
else{Write-Output "$env:COMPUTERNAME Registery.pol dosyasi guncel lakin Update Scan Cycle Tetiklenememistir."}
}
}
else
{
Write-Output " ilgili $path dosya sistem üzerinde mevcut degildir."
Invoke-WmiMethod -computername $env:COMPUTERNAME -Namespace ROOT\ccm -Class SMS_Client -Name TriggerSchedule -argumentList '{00000000-0000-0000-0000-000000000113}' | Out-File c:\temp\$env:COMPUTERNAME-Trigger.txt
if($?){Write-Output " $env:COMPUTERNAME Registery.pol dosyasi mevcut degil bu nedenle sadece Update Scan Cycle Tetiklenmistir."}
else{Write-Output "$env:COMPUTERNAME Registery.pol dosyasi mevcut olmadigi icin sadece Update Scan Cycle Tetiklenememistir."}
}
Comments