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.
This topic is 2 years and 9 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
mar10c--
Posts: 59
Last visit: Mon May 22, 2023 6:53 am

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: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 19
Been upvoted: 37 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: 59
Last visit: Mon May 22, 2023 6:53 am

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
apowershelluser
Posts: 194
Last visit: Fri Mar 22, 2024 4:38 am
Answers: 2

Re: Robocopy in PS 2019

Post by apowershelluser »

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: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 19
Been upvoted: 37 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.
This topic is 2 years and 9 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked