I am using a command line tool called GAMADV-XTD3 to automate a lot of things on my google workspace instance such as email signatures, google drive permissions - etc.
Recently I was asked to also set out of office messages for people that email our HR department with the days that they will be out. I wrote a simple powershell script to input the email address of the user, the start date of their vacation and the end date of their vacation. Using variables I was able to create the string needed for GAM to set the out of office auto reply - but I need to manually copy and paste the command for it to run - is there a way i can pipe out the write-output into running the command it's meant for?
$email = Read-Host -Prompt "enter email"
$startdate = Read-Host -Prompt "enter startdate"
$enddate = Read-Host -Prompt "enter enddate"
Write-Host "gam user $email vacation on subject "`"Out of Office from
$startdate - $enddate`"" message "`"Out of the office from $startdate
to $enddate. If there are any issues or emergencies that you need
addressed in my absence please contact my manager `"" html startdate
$startdate enddate $enddate"
Here is the script I am currently using. As I said - the output is correct in terms of what I need to send as a command - but it currently requires me to copy the output and enter in the command - how can i automate this last step ( push the command that i got out of write-host)