Dan, I know this is an older post but it's relevant to a similar issue I'm having; not only do I have to copy a file, but I also have to create a directory in "C:\Users\%userprofile%\Appdata\Local\" two levels deep, then copy the ini file to the bottom most folder. Using the above, could I do something similar to create the folder structure first, then apply the ini file?
For whatever reason, it's failing to create the directory and of course, isn't copying the file because the directory doesn't exist. Is my code incorrect or...
As reference, I'm using SCCM to deploy this Application, if that matters.
For whatever reason, it's failing to create the directory and of course, isn't copying the file because the directory doesn't exist. Is my code incorrect or...
As reference, I'm using SCCM to deploy this Application, if that matters.
ForEach ($user in (Get-ChildItem "C:\Users" -Exclude Public)) {
New-Item -ItemType Directory -Force -Path "C:\Users\$user\AppData\Local\Folder1\Folder2\"
}
ForEach ($user in (Get-ChildItem "C:\Users" -Exclude Public)) {
Copy-File -Path "$dirFiles\MyFile.txt" -Destination "C:\Users\$user\AppData\Local\Folder1\Folder2\MyFile.ini"
}