Skip to content

Instantly share code, notes, and snippets.

@iamkarlson
Created May 25, 2017 11:31
Show Gist options
  • Select an option

  • Save iamkarlson/283ab751ce332ed8d401bc4e9bd9d821 to your computer and use it in GitHub Desktop.

Select an option

Save iamkarlson/283ab751ce332ed8d401bc4e9bd9d821 to your computer and use it in GitHub Desktop.
get shares from unc path
function Get-Shares(){
param (
[string] $ServerName
)
$out =@()
$netResp = (net view $ServerName)[7..100]
foreach($line in $netResp){
if($line -match "the command completed.*"){
break;
}
$out += $line.Replace(" Disk","").Trim()
}
return $out;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment