Skip to content

Instantly share code, notes, and snippets.

@noahpeltier
Created April 27, 2019 04:30
Show Gist options
  • Save noahpeltier/6127d0057e7568d96fddcb4b11951aa6 to your computer and use it in GitHub Desktop.
Save noahpeltier/6127d0057e7568d96fddcb4b11951aa6 to your computer and use it in GitHub Desktop.
Removes Auvik WIP
$command = New-Object -TypeName System.Text.StringBuilder
$services = New-Object System.Collections.ArrayList
$AuvikPath = 'C:\Auvik'
$DHCPRunning = $null
$EventLogRunning = $null
$AuvikPathExists = $null
Function Script:DeepSearch {
$Drives = @(Get-CimInstance Win32_LogicalDisk -Filter 'DriveType=3')
Write-host "Scanning Directories for files" -ForegroundColor Cyan
Foreach ($drive in $drives) {
Get-childitem -Path "$($drive.DeviceID)\" -Recurse -Filter '*Auvik*' -ErrorAction SilentlyContinue |
Select-Object FullName,LastWriteTime |
ForEach-Object {
$string = "Found $($_.FullName) | last write time $($_.LastWriteTime)"
Write-Host $string -ForegroundColor Yellow
Add-Content -Value $string -Path $logfile
}
}
}
Function Script:RunTests {
$Script:DHCPRunning = [bool](Get-Service 'DHCP client' -ErrorAction SilentlyContinue).status -eq 'Running'
$Script:EventLogRunning = [bool](Get-Service 'EventLog' -ErrorAction SilentlyContinue).status -eq 'Running'
$Script:AuvikPathExists = [bool](Test-Path $AuvikPath)
}
Function StopServices {
If ($DHCPRunning) {Stop-Process 'DHCP Client' -Force}
If ($EventLogRunning) {Stop-Process 'EventLog' -Force}
If ($AuvikPathExists) {Remove-Item -Path $AuvikPath -Force}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment