Forum Discussion
Keke_000
Nov 28, 2023Copper Contributor
copying files to an existing folder
i have a script to detect if a folder existence. I am trying to add to my script of the folder exist just copy the files or how can i have it overwrite the existing folder? Please any guidance is app...
Keke_000
Dec 01, 2023Copper Contributor
I am probably complicating it. the goal is to deploy the folder and its content via intune.
I need to create a folder with its content if it doesnt exist but if it does exist i need it to mirror the folder with it content that i am providing. The script does work when i run it locally. I intune wrap everything and do the deployment but intune is throwing an error that it has installed but cannot locate the file. this is not true since the test machines i tested with did not get the updated files.
I need to create a folder with its content if it doesnt exist but if it does exist i need it to mirror the folder with it content that i am providing. The script does work when i run it locally. I intune wrap everything and do the deployment but intune is throwing an error that it has installed but cannot locate the file. this is not true since the test machines i tested with did not get the updated files.
Deleted
Dec 01, 2023Hello Keke_000
Welcome to the Microsoft community, my name is Recep I'll be happy to help you today.
- Ensure your script logs its activities properly, especially if it's running as a background process. You can redirect output using Out-File or Start-Transcript to capture any errors or debug information.
Start-Transcript -Path "C:\Path\To\Your\LogFile.txt" –Append
- Ensure that the execution policy allows the script to run. You can set the execution policy within the script if needed.
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
- Verify that the account running the script (usually SYSTEM when deployed by Intune) has the necessary permissions to create folders and copy files.
- Set the working directory explicitly at the beginning of your script to avoid any confusion about where the script is running.
Set-Location -Path "C:\Path\To\Your\Script"
- Provide absolute paths for both source and destination. When running as a system process, the working directory might not be what you expect.
- When copying files, provide the full paths. Intune may not resolve relative paths correctly.
- If you're using environment variables, make sure they are resolved correctly when the script runs in the Intune environment.
- Ensure that your Intune deployment configuration specifies the correct script to run and any required parameters.
- For troubleshooting Intune-specific issues, check the Intune Management Extension logs on the target machine. These logs can be found in C:\ProgramData\Microsoft\IntuneManagementExtension\Logs.
- Consider adding a short delay at the beginning of your script to allow the Intune Management Extension to initialize.
Start-Sleep -Seconds 30
If I have answered your question, please mark your post as Solved If you like my response, please give it a Like Appreciate your Kudos! Proud to contribute! 🙂 |