VMware Cloud Community
nava_thulasi39
Jump to solution

Need a script for daily activity

Hi,

I am looking for kind of help to create a script of below task

The task are below.

1. Need to check the VM is powered off.

2. If powered off, I need to rename the display name.

3. Add the notes in the VM

4. Convert it to template

5. Move it to "New Folder" to keep it somedays in the VMs & Templates folder.

Looking for experts help to reduce my manual work. Thanks in advance.

If you find this or any other answer useful please consider awarding points by marking the answer correct or helpful
Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Try something like this

foreach($vm in (Get-VM | where {$_.PowerState -eq "PoweredOff"})){
    Set-VM -VM $vm -Name $newname -Notes $description -Confirm:$false
   
$template = Set-VM -VM $vm -ToTemplate -Confirm:$false
   
Move-Template -Destination (Get-Folder -Name "New Folder") -Template $template -Confirm:$false
}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

Reply
0 Kudos
2 Replies
LucD
Leadership
Leadership
Jump to solution

Try something like this

foreach($vm in (Get-VM | where {$_.PowerState -eq "PoweredOff"})){
    Set-VM -VM $vm -Name $newname -Notes $description -Confirm:$false
   
$template = Set-VM -VM $vm -ToTemplate -Confirm:$false
   
Move-Template -Destination (Get-Folder -Name "New Folder") -Template $template -Confirm:$false
}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
nava_thulasi39
Jump to solution

Thanks. It works perfectly.

if possible Could you please modify this script based on this requirement.

The script should prompt for VM name and description. As i don't have idea how to amend this changes in this script, I am just hitting you again. Smiley Happy

Thanks in advance.

If you find this or any other answer useful please consider awarding points by marking the answer correct or helpful
Reply
0 Kudos