Hi, my name is Anderson Souza, I hope I can help you with your issue.
I believe that your question will be better resolved if it is posted in a more suitable location such as the new Microsoft Q&A forum that is replacing the old TechNet. As it is a question aimed at professionals with scripting skills, I believe that you will get better results there, since this forum here is intended for home Windows users. Please, check the link below:
https://docs.microsoft.com/en-us/answers/products/
You can try posting you question on the PowerShell forum.