Skip to content

List-NetworkShares

List network shares

try {
	if ($IsLinux -or $IsMacOS) {
		# TODO
	} else {
		$shares = Get-WmiObject win32_share | where {$_.name -NotLike "*$"} 
		foreach ($share in $shares) {
			if ($share.Description -eq "") {
				Write-Host "? Folder $($share.Path) shared as: \\$(hostname)\$($share.Name)"
			} else {
				Write-Host "? Folder $($share.Path) shared as: \\$(hostname)\$($share.Name) ('$($share.Description)')"
			}
		}
	}
	exit 0 # success
} catch {
	"?? ERROR: $($Error[0]) (script line $($_.InvocationInfo.ScriptLineNumber))"
	exit 1
}

This script has no configurable parameters.

An interactive directory of PowerShell scripts.