About a month ago, I began studying PS intently.
At that time, I saw where Windows can generate (logs?) PowerShell scripts/cmdlets which mimic the activity that you're doing in the GUI. Maybe that was wishful dreaming??
At the time, I thought that I would come back to that after I delved into the cmdlets, etc.