agingnerds

Untitled

Jan 29th, 2018
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #This is a script to map network drives. It uses a password and user name so it can be accessed by a domain user
  2.  
  3. #This section are the different variables that are used
  4.  
  5. #Username is the domain username. Should not need to change unless we are no longer able to use it
  6. $User = "Username removed"
  7.  
  8. #The is the only thing that should need to be updated text after -string
  9. $PWord = ConvertTo-SecureString -string "password removed" -AsPlainText -force
  10.  
  11. #This part is how the password is grabbed. Do not mess with
  12. $credential = New-Object -TypeName "system.management.automation.pscredential" -argumentlist $user, $PWord
  13.  
  14. #If for remove drive and add drive to ses (need to come back and work on this command. Leaves red marks.
  15. If ((Get-PSDrive).Name -eq 'X') {Remove-PSDrive -Name 'X'}
  16.     Get-PSDrive
  17.  
  18. If (!(get-psdrive 'x')) {new-PSDrive -name 'x' -PSProvider FileSystem -Persist -root \\server\folder1 -Credential $credential -scope global}
  19.  
  20. #If for remove drive and add drive to Folder2
  21. If ((Get-PSDrive).Name -eq 'y') {Remove-PSDrive -Name 'y'}
  22.  
  23. If (!(get-psdrive 'y')) {new-PSDrive -name 'y' -PSProvider FileSystem -Persist -root \\server\folder2 -Credential $credential -scope global}
  24.  
  25. #If for remove drive and add drive to Folder3
  26. If ((Get-PSDrive).Name -eq 'z') {Remove-PSDrive -Name 'z'}
  27.  
  28. 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