$AllDfs = Get-DfsnRoot
$BodyHtml = '
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
* {
box-sizing: border-box;
}
#myInput {
background-position: 10px 10px;
background-repeat: no-repeat;
width: 100%;
font-size: 16px;
padding: 12px 20px 12px 40px;
border: 1px solid #ddd;
margin-bottom: 12px;
}
#myTable {
border-collapse: collapse;
width: 100%;
border: 1px solid #ddd;
font-size: 18px;
}
#myTable th, #myTable td {
text-align: left;
padding: 12px;
}
#myTable tr {
border-bottom: 1px solid #ddd;
}
#myTable tr.header, #myTable tr:hover {
background-color: #f1f1f1;
}
</style>
</head>
<body>
<h2>DFS Spaces</h2>
<input type="text" id="myInput" onkeyup="myFunction()" placeholder="Search for Target folder.." title="Type in a target folder">
<table id="myTable">
<tr class="header">
<th style="width:20%;">Spaces</th>
<th style="width:30%;">Spaces folder</th>
<th style="width:30%;">Target folder</th>
<th style="width:10%;">Status Folder</th>
</tr>'
foreach ($CurrentDfs in $AllDfs){
$DFSRoot = $CurrentDfs
$DFSrootPath = $DFSRoot.path
Write-Host 'Пространство' $DFSRoot.path -ForegroundColor Green -BackgroundColor Red
ForEach-Object {
$DFSFolder = Get-DfsnFolder -Path ($DFSRoot.path + "\*")
foreach ($DFSFolder1 in $DFSFolder){
$DFSFOLPATH = $DFSFolder1.path
Write-Host `t'Имя папки' $DFSFolder1.path -ForegroundColor Yellow -BackgroundColor Red
$DFSTargetfolder = Get-DfsnFolderTarget $DFSFolder1.path
foreach ($DFSTargetfolder1 in $DFSTargetfolder){
$DFSTARGT = $DFSTargetfolder1.TargetPath
$TargetFolderStatus = $DFSTargetfolder1.State
Write-Host `t`t'Конечная ссылка папки' $DFSTargetfolder1.TargetPath -ForegroundColor Black -BackgroundColor Red
$arr += @(
New-Object PSObject -Property @{DFSRootPath = "$DFSrootPath"; DFSRootFolder = "$DFSFOLPATH"; TargetFolder = "$DFSTARGT"; TargetFolderStatus = "$TargetFolderStatus"}
)
if($DFSTargetfolder1.State -match "Online")
{
Write-Host `t`t`t'Ссылка включена' -ForegroundColor Yellow -BackgroundColor Green
}else{Write-Host `t`t`t'Ссылка отключена' -ForegroundColor Yellow -BackgroundColor red}
}
}}}
$BodyHtml3 = '</table>
<script>
function myFunction() {
var input, filter, table, tr, td, i;
input = document.getElementById("myInput");
filter = input.value.toUpperCase();
table = document.getElementById("myTable");
tr = table.getElementsByTagName("tr");
for (i = 0; i < tr.length; i++) {
td = tr[i].getElementsByTagName("td")[2];
if (td) {
if (td.innerHTML.toUpperCase().indexOf(filter) > -1) {
tr[i].style.display = "";
} else {
tr[i].style.display = "none";
}
}
}
}
</script>
</body>
</html>
'
foreach ($arr1 in $arr){
$BodyHtml4 += "<tr><td>"+ $arr1.DFSRootPath +"</td>"
$BodyHtml4 += "<td>"+ $arr1.DFSRootFolder +"</td>"
$BodyHtml4 += "<td>"+ $arr1.TargetFolder +"</td>"
$BodyHtml4 += "<td>"+ $arr1.TargetFolderStatus +"</td></tr>"
}
$totalBody = $BodyHtml + $BodyHtml4 + $BodyHtml3
$totalBody > c:\temp\dfs_link.html