Thanks for the post and providing best practices in hiding plain text passwords in the code.
However, it should still be noted that “$Password = $in.GetNetworkCredential().password” will have your password stored in the variable and could be printed out if one wishes to do so. Like you mentioned, this is just a ‘small’ security and a person knowing a bit more would be able to identify this.
Get-Credential is another good practice to use, but it isn’t viable for the normal user who dislikes re-entering their credentials every time. This was created on the notion for the normal user, not a technical user which is why I simplified the code as much as I could.
I do really appreciate the post as I learned something more about PowerShell from your post. Thanks!