Created
February 12, 2019 05:08
-
-
Save HumanEquivalentUnit/6caf24d9c262e4fa936a55fcb83f314a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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