PowerShell to Copy File for Google

I am having an issue where the Master_Preferences file is not getting copied to the target location. I have the constraint of creating a package for every new version and I am getting away from batch files. the post-deployment this is not working…it is supposed to check for the 64 bit structure and copy the file if the folder is there, otherwise copy the folder to the 32 bit folder structure. Thanks -

  $Master_Preferences = '$dirSupportFiles\master_preferences.file'
   $secondpath = "c:\Program Files\Google\Chrome\Application\"
   $ValidPath = test-path "c:\Program Files (x86)\Google\Chrome\Application\" -IsValid

   if ($ValidPath -eq $true ) 
    {copy-item -path "$Master_Preferences" -Destination "$ValidPath"} 
    {copy-item -path "$Master_Preferences" -Destination "$secondpath"}

Remove -IsValid from test-path. The Isvalid parameter will always return true.

From the help:


Indicates that this cmdlet tests the syntax of the path, regardless of whether the elements of the path exist. This cmdlet returns $True if the path syntax is valid and $False if it is not.

1 Like

You can use this:

$Master_Preferences = ‘$dirSupportFiles\master_preferences.file’
$secondpath = “c:\Program Files\Google\Chrome\Application”
$ValidPath = “c:\Program Files (x86)\Google\Chrome\Application”

if (test-path $ValidPath)
{copy-file -path “$Master_Preferences” -Destination “$ValidPath”}
{copy-file -path “$Master_Preferences” -Destination “$secondpath”}