i'm pretty new to powershell, and haven't been able to figure out a solution to the following problem.
the company i work for need to retain files from terminated workers for a certain amount of time. i am trying to automate the task through a powershell script. for the most part i have it figured out how to pull only the files i want from the folders i want.
the issue i have is with the desktop folder. i need it to pull all information whether it is on the desktop or in a folder that is on the desktop. the problem comes in with the copy-item -recurse function. if there are no extra folders on the desktop, it will error. if i don't include the recurse option, it will only pull in the data on the desktop and no data from the subfolders.
so my question is this...using the powershell script, how would i check for subfolders and then if subfolders exist, run the command with the recurse option, else run it without.
if there is anything i'm missing, please let me know. like i said, i'm new to powershell and am still trying to figure it out.
Mag
the company i work for need to retain files from terminated workers for a certain amount of time. i am trying to automate the task through a powershell script. for the most part i have it figured out how to pull only the files i want from the folders i want.
the issue i have is with the desktop folder. i need it to pull all information whether it is on the desktop or in a folder that is on the desktop. the problem comes in with the copy-item -recurse function. if there are no extra folders on the desktop, it will error. if i don't include the recurse option, it will only pull in the data on the desktop and no data from the subfolders.
so my question is this...using the powershell script, how would i check for subfolders and then if subfolders exist, run the command with the recurse option, else run it without.
if there is anything i'm missing, please let me know. like i said, i'm new to powershell and am still trying to figure it out.
Mag