Advertisement
Guest User

Untitled

a guest
May 23rd, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. Function exposeRepository
  2. {
  3.  
  4. Param
  5. (
  6. )
  7.  
  8. Begin
  9. {
  10. }
  11.  
  12. Process
  13. {
  14. ###########################
  15. #Create PSCredential Object
  16. ###########################
  17. [String] $userVar = "DOMAIN\firstname_lastname"
  18. [String] $stringFile = ".\encrypt.d\repository.con"
  19. [String] $keyFile = ".\encrypt.d\repository.key"
  20. [Array] $keyVar = Get-Content $keyFile
  21. $credObj = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $userVar, (Get-Content $stringFile | ConvertTo-SecureString -Key $keyVar)
  22.  
  23. ###################
  24. #Mount Remote Share
  25. ###################
  26. [String] $repoName = "U"
  27. [String] $repoPath = "\\remotehost.institution.edu.au\EXTDRIVE\SSM\fileStore"
  28. [Array] $listDrives = Get-PSDrive
  29.  
  30. If ($listDrives.Name -contains $repoName)
  31. {Remove-PSDrive -Name $repoName -Scope Global}
  32.  
  33. Else
  34. {
  35. New-PSDrive -Name $repoName -PSProvider FileSystem -Root $repoPath -Credential $credObj -Scope Global -Persist
  36. }
  37.  
  38. }
  39.  
  40. End
  41. {
  42. }
  43.  
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement