Copy files to AppData Local

Comments

4 comments

  • Kris Powell

    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
    Comment actions Permalink
  • Steven Toro

    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
    Comment actions Permalink
  • Colby Bouma

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

    0
    Comment actions Permalink
  • Stephen Valdinger

    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
    Comment actions Permalink

Please sign in to leave a comment.