Created
December 19, 2012 15:52
-
-
Save rarous/4337734 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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