# encoding: ascii
# api: powershell
# title: Sys. Adm
# description: Get-NetView
# version: 0.1
# type: function
# author: Daniel
# license: CC0
# function: Get-NetView
# x-poshcode-id: 4186
# x-archived: 2013-06-12T03:01:33
# x-published: 2013-05-29T09:20:00
#
#
function Get-NetView {
param($Computer)
$Result = @()
$ses = NET.EXE VIEW $Computer
$ColLength = -1
$start = -1
for($i = 0; $i -lt $ses.Count;$i++)
{
$temp =$null
$temp = $ses[$i]
if($temp -like "-----------------*")
{
#Start Parse
$start = $i+1
}
if($temp -eq "The command completed successfully.")
{
#End Parse
$start = -1
}
if($temp -like "Share name*Type*")
{
#Determine Length
$end = $temp.IndexOf("Type")
$ColLength = $end
}
if($i -ge $start -and $start -ne -1)
{
#Find Share
$parts =$temp.Substring(0,$ColLength)
$share = ("\\" + $Computer + "\" + $parts.Trim())
$obj = New-Object PSObject
$obj | Add-Member -MemberType NoteProperty -Name "Share" -Value $share
$Result += $obj
}
}
return $Result
}
#Usage
Get-NetView DFSROOT01 | ft -AutoSize