PoshCode Archive  Artifact [d533ef8364]

Artifact d533ef8364e9a4d519b9fabb652899cce71998bad95cc3754b966d0fa66b9df8:

  • File Sys-Adm.ps1 — part of check-in [8df0043a08] at 2018-06-10 13:37:51 on branch trunk — Get-NetView (user: Daniel size: 1167)

# 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