Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check if the folder exists. #3

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion ManageWECRegistry.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
$subscription = 'Default'
$Folder = 'C:\scripts'
"Test to see if folder [$Folder] exists"
if (Test-Path -Path $Folder) {
} else {
md $Folder > $null
}
if(Test-Path -Path C:\scripts\ManageWECRegistry.log){
Move-Item C:\scripts\ManageWECRegistry.log C:\scripts\ManageWECRegistry.log.bak -Force
}
Expand All @@ -19,4 +25,4 @@ $subscribed_computers | Where-Object { $computers -notcontains $_ } | ForEach-Ob
"Removing computer $computer_name from WEC registry" | Out-File -FilePath C:\scripts\ManageWECRegistry.log -Append -Encoding ascii
Remove-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\EventCollector\Subscriptions\$subscription\EventSources\$computer_name" -Force -Verbose
}
Get-Date | Out-File -FilePath C:\scripts\ManageWECRegistry.log -Append -Encoding ascii
Get-Date | Out-File -FilePath C:\scripts\ManageWECRegistry.log -Append -Encoding ascii