Last active
February 10, 2017 23:48
-
-
Save davewilson/c39705fb983525bdea76 to your computer and use it in GitHub Desktop.
Mounts and Dismounts commonly used network shares
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
<# | |
.Synopsis | |
Maps commonly used network shares | |
.DESCRIPTION | |
Maps drives for commonly used network shares. Username parameter will map the drives as a specific user | |
.EXAMPLE | |
Mount-CommonShare | |
.EXAMPLE | |
Mount-CommonShare -Username stcxyz | |
#> | |
function Mount-CommonShare | |
{ | |
[CmdletBinding()] | |
[OutputType([int])] | |
Param | |
( | |
[Parameter(ValueFromPipelineByPropertyName=$true, | |
Position=0)] | |
$Username | |
) | |
if ($Username -eq $null) | |
{ | |
New-PSDrive -Name "Z" -PSProvider FileSystem -Root "\\server1\share" -Persist -Scope global | |
New-PSDrive -Name "Y" -PSProvider FileSystem -Root "\\server2\share" -Persist -Scope global | |
New-PSDrive -Name "X" -PSProvider FileSystem -Root "\\server3\share" -Persist -Scope global | |
} | |
else | |
{ | |
New-PSDrive -Name "Z" -PSProvider FileSystem -Root "\\server1\share" -Persist -Scope global -Credential $Username | |
New-PSDrive -Name "Y" -PSProvider FileSystem -Root "\\server2\share" -Persist -Scope global -Credential $Username | |
New-PSDrive -Name "X" -PSProvider FileSystem -Root "\\server3\share" -Persist -Scope global -Credential $Username | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment