I am attempting to set the hidden attribute on a few files that I copied using the Copy-File function in an SCCM Task Sequence. To do so, I’m using the attrib.exe program built into Windows. When I run the following three functions on my main machine in a non TS Environment, I have no issues. When this runs in a Task Sequence, the function errors out with a return code of -1073741502. The log shows the correct command is being executed.
Execute-Process -Path “attrib.exe” -Parameters “+h C:\file.exe”
Execute-Process -Path “attrib.exe” -Parameters “+h C:\file.xsl”
Execute-Process -Path “attrib.exe” -Parameters “+h C:\file.gif”
In the Task Sequence environment, I tried running these commands in the command prompt and was successful.
I then created a batch file (attribs.bat) with these commands and executed the batch file successfully through the command prompt. Finally, I called the batch file from the PSDT and encountered the same error as I originally had. This batch file also has logging functionality which were not created at the time of execution leading me to believe the PSDT is not successfully launching the batch file or the processes explained earlier.
Execute-Process -Path “attribs.bat”
Execute-Process -Path “cmd.exe” -Parameters “attribs.bat”
Please let me know if you have any suggestions or need any additional information from me.