Powershell and robocopy

reredok used Ask the Experts™
Hi Experts,

is there any way to ascertain if a robocopy call in Powershell support the /MT:n switch before running robocopy. Remember robocopy before Windows 2008 R2 Server have no /MT Switch.
$LASTEXITCODE give only "success" or "fail" (ERRORLEVEL) but not if the robocopy Version support the switch.


Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
IT Consultant
got it:
if ($version_Major -le 6) {
    if($version_Minor -eq 0) {
        $Windows_2008_Server = $true
    } # if
    else {
        if ($version_Minor -gt 0) {
            $Windows_2008_Server = $false 
            }# if
    } # else
} # if

Open in new window

depending on !($Windows_2008_Server) you can set /MT Switch for newer OS like Windows 2008 Server
Qlemo"Batchelor", Developer and EE Topic Advisor
Top Expert 2015

There could be a more recent Robocopy somewhere copied to the system, but yes, the OS release check should work in general. Parsing e.g. robocopy help would be more reliable, though.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial