Pages: [1]
Print
Author Topic: ConvertTo-Template.ps1  (Read 1077 times)
ewannema
Administrator
Newbie
*****
Posts: 33


View Profile WWW
« on: March 10, 2009, 11:56:08 AM »

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.

Code:
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 $_
}
Logged
esarakaitis
Administrator
Sr. Member
*****
Posts: 256


8223109 sack57@hotmail.com littleking57 rootinfortwayne
View Profile WWW Email
« Reply #1 on: March 10, 2009, 12:46:34 PM »

very nice!
Logged
Pages: [1]
Print
Jump to: