Often, you first play around with PowerShell commands interactively, and then once those commands do what you want, you can copy them to your script editor and turn them into scripts and functions. Here is a little helper function that takes all your...