Robocopy in PS 2019

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Locked
User avatar
mar10c
Posts: 21
Last visit: Fri Jun 11, 2021 12:36 pm

Robocopy in PS 2019

Post by mar10c »

This works in Powershell ise but not in Powershell Studio 2019 ?

$FilePath = "C:\test\mcc"
$rmtcomp = '192.168.1.4'
$rmtdst = 'C$'
$rmtdest = '\\$rmtcomp\$rmtdst'
Robocopy $FilePath \\$rmtcomp\$rmtdst\mcc /MIR

User avatar
Alexander Riedel
Posts: 7719
Last visit: Sat Jul 31, 2021 12:28 pm
Answers: 4
Been upvoted: 10 times

Re: Robocopy in PS 2019

Post by Alexander Riedel »

Define "not work". If you get an error message, please post the message.
Alexander Riedel
SAPIEN Technologies, Inc.

User avatar
mar10c
Posts: 21
Last visit: Fri Jun 11, 2021 12:36 pm

Re: Robocopy in PS 2019

Post by mar10c »

Does "not work" meaning it does not copy. I'm looking at which offer best performance for large files Robocopy or Copy-Item. Just curious why PS 2019 does not perform Robocopy to a remote system while the PS ISE does.

User avatar
JohnTitor
Posts: 163
Last visit: Tue Jul 27, 2021 5:57 am

Re: Robocopy in PS 2019

Post by JohnTitor »

It absolutely works , it even works in WindowsPE
remove the variables and just type it out to ensure you're getting the results in PSS that you expect and then create the variables

User avatar
Alexander Riedel
Posts: 7719
Last visit: Sat Jul 31, 2021 12:28 pm
Answers: 4
Been upvoted: 10 times

Re: Robocopy in PS 2019

Post by Alexander Riedel »

The usually suspects when something is 'not working' are
- Permissions. Is the ISE running elevated but you are not running the script elevated from PowerShell Studio
- Runspace contamination. The ISE, as well as the console, keep variables around until you exit. In PowerShell Studio a script always runs in a new process.
- Firewalls. If you have a corporate firewall, the ISE may have an exception, Scriptdriver64.exe may not.

Robocopy displays an error message when it cannot copy as instructed. It doesn't simply not copy and is quiet about it.
Please always post any error message you get, saying 'not working' only leads to guesswork.
Alexander Riedel
SAPIEN Technologies, Inc.

Locked