Accepts VM objects as parameters or in the pipeline and converts them to templates. Powershell v2 makes this prettier and a little more robust, but I thought that this would apply to more people.
BEGIN
{
Function ConvertTo-Template
{
param
(
$vm
)
if ($vm)
{
$vmview = Get-View $vm.ID
$vmview.MarkAsTemplate()
}
}
foreach ($vm in $args)
{
ConvertTo-Template $vm
}
}
PROCESS
{
ConvertTo-Template $_
}