What do you want to export, the names of the VMs and how they were stopped ?
If you put the above code in a separate .ps1 file, you can add a param statement and use that on the Name parameter of the Get-VM cmdlet.
Like this
Param([string[]]$VMNames)
Get-VM -Name $VMNames | %{
if($_.ExtensionData.Guest.ToolsRunningStatus -eq "GuestToolsNotRunning"){
Stop-VM -VM $_ -Confirm:$false
}
else{
Shutdown-VMGuest -VM $_ -Confirm:$false
}
}
Now you can call this
.\myscript.ps1 -VMNames $vmspwof