Deploying files to appdata\roaming using PSADTK and Intune

Kiyomi 0 Reputation points
2023-11-30T01:17:39.17+00:00

I need help deploying Templates to the following location:

c:\users\username\appdata\roaming\microsoft\templates\the new folder

This is my current script:

$CurrentUserName = $RunAsActiveUser.UserName
if ($CurrentUserName)
{
  Copy-File -Path '$dirFiles\Charts' -Destination '$envSystemDrive\Users\$CurrentUserName\AppData\Roaming'
}

However, it creates a new folder (WRan5310wx) instead of inserting it under the appdata location (WRandolph). Here is a screenshot:

snip

Microsoft Intune Application management
Microsoft Intune Application management
Microsoft Intune: A Microsoft cloud-based management solution that offers mobile device management, mobile application management, and PC management capabilities.Application management: The process of creating, configuring, managing, and monitoring applications.
922 questions
Microsoft Intune
Microsoft Intune
A Microsoft cloud-based management solution that offers mobile device management, mobile application management, and PC management capabilities.
4,771 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,351 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Crystal-MSFT 46,351 Reputation points Microsoft Vendor
    2023-11-30T01:45:45.82+00:00

    @Kiyomi, Thanks for posting in Q&A. For the issue, I think the issue is that the variable under different account is different. For the script deployed from Intune, it has an option "Run this script using the logged on credentials". When we set it as Yes, it will run the script with the user's credentials on the device. Choose No to run the script in the system context Please check which value we set.

    https://learn.microsoft.com/en-us/mem/intune/apps/intune-management-extension

    Meanwhile, for the script, I find the command has some issue. You can change the "Copy-File" command to the following one to see if it works.

    Copy-File -Path $dirFiles+'\Charts' -Destination $env:SystemDrive+'\Users\'+$CurrentUserName+'\AppData\Roaming'
    

    Please check the above information and if there's any update, feel free to let us know.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.