Last active
July 25, 2019 16:29
-
-
Save MartinMiles/32ec39117afb70dcfc58af831de0a0af to your computer and use it in GitHub Desktop.
This copies a local file to the remote machine using PowerShell remote session with credentials provided
This file contains 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
$pass = ConvertTo-SecureString -AsPlainText '123' -Force # 123 - actual password | |
$Cred = New-Object System.Management.Automation.PSCredential -ArgumentList 'Martin',$pass # Martin - actual username | |
$Session = New-PSSession -ComputerName 192.168.173.14 -Credential $Cred # IP address of remote machine | |
$remotePath = Invoke-Command -Session $session -ScriptBlock { New-Item -ItemType Directory -Force -Path Sifon } #Get-Location | |
Copy-Item -Path "c:\Some\Path\To\Local\Script.ps1" -Destination $remotePath.FullName -ToSession $session | |
Remove-PSSession $Session |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment