Marcus Lindh

I have created a Powershell function to create a RAR archive.

With -ep1 parameter flag it excludes base directory for the name on files in the archive.

$WinRAR = "C:\Program Files\WinRAR\rar"
    
Function CreateRAR($Folder, $RAR, $Name){
    $CreationDate = Get-Date -format yyyy-MM-dd
    $Path = $RAR + $Name + " " + $CreationDate + ".rar"
    
    & $WinRAR a -ep1 $Path $Folder
}

CreateRAR "C:\Program Files (x86)" "c:\" "Program Files"
    

The name of the archive is "Program Files .rar"