Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #This is a script to map network drives. It uses a password and user name so it can be accessed by a domain user
- #This section are the different variables that are used
- #Username is the domain username. Should not need to change unless we are no longer able to use it
- $User = "Username removed"
- #The is the only thing that should need to be updated text after -string
- $PWord = ConvertTo-SecureString -string "password removed" -AsPlainText -force
- #This part is how the password is grabbed. Do not mess with
- $credential = New-Object -TypeName "system.management.automation.pscredential" -argumentlist $user, $PWord
- #If for remove drive and add drive to ses (need to come back and work on this command. Leaves red marks.
- If ((Get-PSDrive).Name -eq 'X') {Remove-PSDrive -Name 'X'}
- Get-PSDrive
- If (!(get-psdrive 'x')) {new-PSDrive -name 'x' -PSProvider FileSystem -Persist -root \\server\folder1 -Credential $credential -scope global}
- #If for remove drive and add drive to Folder2
- If ((Get-PSDrive).Name -eq 'y') {Remove-PSDrive -Name 'y'}
- If (!(get-psdrive 'y')) {new-PSDrive -name 'y' -PSProvider FileSystem -Persist -root \\server\folder2 -Credential $credential -scope global}
- #If for remove drive and add drive to Folder3
- If ((Get-PSDrive).Name -eq 'z') {Remove-PSDrive -Name 'z'}
- If (!(get-psdrive 'z')) {new-PSDrive -name 'z' -PSProvider FileSystem -Persist -root \\server\folder3 -Credential $credential -scope global}
Advertisement
Add Comment
Please, Sign In to add comment