Important Notice: On February 29th, this community was put into read-only mode. All existing posts will remain but customers are unable to add new posts or comment on existing. Please feel to join our Community Discord for any questions and discussions.

Copy files to AppData Local

Hi there 

We're using PDQ deploy pro and wanted to copy an xml file to all user profiles (windows 7) to this location %USERPROFILE%\AppData\Local 

When I use the path above it only copies the files to the existing profile that PDQ is using which is a domain admin account on the machine that i'm testing.

How can i copy it to all user profiles

 

0

Comments

4 comments
Date Votes
  • Hello!

    That is a great question! The reason that it's only copying your file to your PDQ account profile is because the %USERPROFILE% is a user environment variable. That means that it's specific to the user account that's using it.

    If you log in as User1 and look at the %USERPROFILE% environment variable, it will show C:\Users\User1. If you log in as User5 and look at the %USERPROFILE% environment variable, it will show C:\Users\User5.

    Since the PDQ Deploy account is connecting to your target as the Deploy User, it will use the %USERPROFILE% for your Deploy User.

    Personally, I'm fond of PowerShell (check out my blog!), so here's how you could copy a file into each users directory by using PowerShell. I'm traversing each directory in C:\Users by utilizing a wildcard (*) and then I'm looping through and copying each file based upon the results:

    • Create a PowerShell file (Just open notepad and save the file as .ps1. For example, MyScript.ps1)
    • In the  .ps1 file, copy the following (modify the $Source file to wherever your file resides):
    $Source = 'C:\test\example.xml'
    $Destination = 'C:\users\*\AppData\Local'
    Get-ChildItem $Destination | ForEach-Object {Copy-Item -Path $Source -Destination $_ -Force}
    • Add your new .ps1 file to an Install step
    • Deploy to your targets

    I've also attached a couple of screenshots as examples. Best of luck to you!

    Cheers,

    Edit: I cleaned up my text and added some extra explanations. I hope they're helpful!

     

    3
  • Kris,

    From my understanding on PowerShell, the target PC would need to have certain execution policies enabled in order to run this.

    Is there an easier way without powershell to accomplish the same thing? perhaps a batch file or using the target folder options in the package properties of PDQ Deploy?

    0
  • PowerShell should work with Deploy by default unless you enforce extra restrictions.

    0
  • When they launch powershell during a deployment they actually start the process like this: powershell.exe -ExecutionPolicy Bypass (I think it's bypass, might not be), regardless, they launch powershell with the ability to run powershell scripts.

     

    So yes, the powershell code above should work just fine barring any ridiculous security policies being applied to the system.

    0