Copying two files to all logged in users in DESKTOP

Hello All,

I’m trying to execute setup file first which works fine and then there is two files i would like to copy to desktop for all logged in users on the system, not sure why the copy part not working if someone can can suggest or have different way of doing to copy the two files from $dirSupportFiles to Desktop of all logged in users in the system.

Execute-Process -Path 'windowsdesktop-runtime-7.0.4-win-x64.exe' -Parameters '/q' -wait -passthru
Copy-File -Path $dirSupportFiles\* -Destination C:\users*\Desktop\ -Recurse

How about using the custom function inside PSAD
Execute-ProcessAsUser

Then use that to either copy the files or run a .ps1 file that does copy ?

Option #2 You could use Active setup, to make sure it’s copied for any user(s) on the machine.
the function is called Set-ActiveSetup, I have done this for apps that need each user to connect to a server I setup something inside HKCU for all of them

FYI: The active setup would be able to handle current existing users and future users of the desktop.

Thanks for replying, I wanted to use something that when i run this via the SCCM it will run as system environment and wont work, I was wondering if something. to take care of all logged in users to copy, I will try the method shared by you, Thank you.

1 Like

Hey,

active setup is not the best way…

Try…

        [string[]]$ProfilePaths = Get-UserProfiles | Select-Object -ExpandProperty "ProfilePath"
        ForEach($UserProfilePath in $ProfilePaths) {
            Write-Log -Message "Edit userprofile: [$UserProfilePath]" -Source $installPhase
            Copy-File -Path "$dirFiles\XXXXX" -Destination "$UserProfilePath\...." -ContinueOnError $false
        }
2 Likes

Thank you, i will try this and see how it goes.

This worked like charm via SCCM, thank you very much appreciate it.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.