Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Need to push a file to a remote machine (not in a domain)

$
0
0

Im a little new to Powershell.  Have scripted in VB and written some basic Apps in C# so I don't think what Im asking here is difficult in anyway.  Just need advice on how I should approach this in powershell. 

Scenario

HomeComputer

MyCloudServer 

 

(no workgroup or domains between the 2)

 

All I need to do is push a file to the server.  I've played with Invoked-Commands remotely and can makes changes on the server.  Example script here. 

    Try
    {
    Invoke-Command -ConnectionUri https://mycloudserver.net:5986 -ScriptBlock { Restart-    Service Themes } -credential TestUser
    }
    Catch
    {
     write-host "Exception Type: $($_.Exception.GetType().FullName)" -ForegroundColor Red
     write-host "Exception Message: $($_.Exception.Message)" -ForegroundColor Red
    }
    Finally
    {
     write-host "Finished!"
     }
This all works.  But what if I want to copy a file from HomeComputer to MyCloudServer.  Copy-Item is executing on the remote computer it seems.  Is there a way I can pass in a reference back to my HomeComputer file while it has the remote powershell session with MyCloudServer running? 
Also been lookiing at Start-BitsTransfer but havent been able to got that to work. 
Start-BitsTransfer D:\testfile1.txt https://MyCloudServer.net:5986/testfolder/testfile1.txt -TransferType Upload -Authentication "" -Credential ""
I get requested URL doesn't exist on destination (which is obvious because Im trying to upload it).  The only thing that doesn't exist in the 'https://MyCloudServer.net:5986/testfolder/testfile1.txt' path is the testfile1.txt file
I feel like I'm missing a better way to do this.  Seems like it should be pretty simple. 
Appreciate any help.  Thanks!

Viewing all articles
Browse latest Browse all 6937

Trending Articles