Have you read this? It's right at the top of the Windows-Server-Powershell section. Technical questions about explanation and correction of commands, advice for PowerShell scripts, and troubleshooting PowerShell-related issues.
Have you even tried to find something that someone has written, and published, before that might meet your requirement -- or that you, with a little bit of work, might tailor to your specific requirements? There are MANY scripts that are free for you to use. All you have to do is look for them. Here are just a few that I found in about 30 seconds: