Skip to content

Instantly share code, notes, and snippets.

@rarous
Created December 19, 2012 15:52
Show Gist options
  • Select an option

  • Save rarous/4337734 to your computer and use it in GitHub Desktop.

Select an option

Save rarous/4337734 to your computer and use it in GitHub Desktop.
param(
[Parameter(Position = 0, Mandatory = $true)]$serverIP,
[Parameter(Position = 1, Mandatory = $true)]$mountServerName,
$mountDirectory = "c:\mnt\")
Import-Module MkLink # https://gist.github.com/2891103
if (-not (Test-Path $mountDirectory)) {
Write-Error "Invalid mount directory - $mountDirectory"
exit 81
}
if (-not (Test-Connection $serverIP)) {
Write-Error "network problem - $serverIP"
exit 82
}
$mountDir = Join-Path $mountDirectory $mountServerName
if (-not (Test-Path $mountDir)) {
mkdir $mountDir
}
Get-WmiObject -Class Win32_Share -ComputerName $serverIP | Foreach {
$path = Join-Path $mountDir $_.Name
$share = $_.Path
Write-Debug $path
Write-Debug $share
New-SymLink $path $share
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment