Check if a certain UNC path exists on all active AD Servers

 

Formatting looks very bad, but this word-press doesn’t let me formatted as I like.

$pcs = get-adcomputer -filter {operatingsystem -like "*server*"} 
$result = @()
foreach ($pc in $pcs) {
    if (test-connection -cn $pc.Name -count 1 -Quiet) {
        $path1 = ("\\{0}\c$\windows\microsoft.net\framework\v3.5" -f $pc.name) 
        $result = test-path -path $path1 
        $isVirtual = ((Get-WmiObject Win32_BIOS -ComputerName $pc.name).SerialNumber -match "VMware")
        New-Object PSObject -Property @{
            Computer = $pc.name;
            Path = $path1;
            Virtual = $isVirtual;
            Result = $result
        }
    }
}
$result | export-csv c:\TemporaryFolder\results.csv