Last active
January 24, 2020 12:23
-
-
Save mika76/6709a69f43ae225f069003700b655a52 to your computer and use it in GitHub Desktop.
TFS powershell copy items to unc with credentials
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
# Create credential from user pass strings | |
$User = "192.168.0.10\administrator" | |
$PWord = ConvertTo-SecureString -String "pass123" -AsPlainText -Force | |
$Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User, $PWord | |
# Create mapped drive Y: with the UNC path | |
New-PSDrive -Name Y -PSProvider filesystem -Root "\\192.168.0.10\sharedfolder" -Credential $Credential | |
# Copy files to Y: drive | |
copy -Path '$(build.sourcesdirectory)\Project\bin\Release\**' -Destination Y:\ -Recurse -Force | |
# Remove Y: drive | |
Remove-PSDrive Y |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment