Skip to content

Instantly share code, notes, and snippets.

@mika76
Last active January 24, 2020 12:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mika76/6709a69f43ae225f069003700b655a52 to your computer and use it in GitHub Desktop.
Save mika76/6709a69f43ae225f069003700b655a52 to your computer and use it in GitHub Desktop.
TFS powershell copy items to unc with credentials
# 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