Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HumanEquivalentUnit/6caf24d9c262e4fa936a55fcb83f314a to your computer and use it in GitHub Desktop.
Save HumanEquivalentUnit/6caf24d9c262e4fa936a55fcb83f314a to your computer and use it in GitHub Desktop.
# Parameters
param(
[string] $ComputerList = $(Join-Path -Path $PSScriptRoot -ChildPath "computers.txt"), # Path to the list of computers
[string] $ReportPath = $(Join-Path -Path $PSScriptRoot -ChildPath "report.csv"), # Path to the report to output
[switch] $DeleteFolder = $false # Whether to delete MININT or not
)
Get-Content $ComputerList | ForEach-Object {
$result = @{
could_connect = $false
found_minint = $false
deleted_minint = $false
}
try
{
$minint_folder = Get-ChildItem -Force \\$_\c$\MININT -ErrorAction Stop
$result.could_connect = $true
if ($minint_folder)
{
$result.found_minint = $true
if ($DeleteFolder)
{
try
{
Remove-Item -Path \\$_\c$\MININT -Force -ErrorAction Stop
$result.deleted_minint = $true
}
catch {}
}
}
}
catch {}
[PSCustomObject]$result
} | Export-Csv -Path $ReportPath -NoTypeInformation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment