Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Function exposeRepository
- {
- Param
- (
- )
- Begin
- {
- }
- Process
- {
- ###########################
- #Create PSCredential Object
- ###########################
- [String] $userVar = "DOMAIN\firstname_lastname"
- [String] $stringFile = ".\encrypt.d\repository.con"
- [String] $keyFile = ".\encrypt.d\repository.key"
- [Array] $keyVar = Get-Content $keyFile
- $credObj = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $userVar, (Get-Content $stringFile | ConvertTo-SecureString -Key $keyVar)
- ###################
- #Mount Remote Share
- ###################
- [String] $repoName = "U"
- [String] $repoPath = "\\remotehost.institution.edu.au\EXTDRIVE\SSM\fileStore"
- [Array] $listDrives = Get-PSDrive
- If ($listDrives.Name -contains $repoName)
- {Remove-PSDrive -Name $repoName -Scope Global}
- Else
- {
- New-PSDrive -Name $repoName -PSProvider FileSystem -Root $repoPath -Credential $credObj -Scope Global -Persist
- }
- }
- End
- {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement