LauraLeigh's Posts

Yes I'm sure. The output when adding that line: class ScheduledTaskSpec {   Name = Snapshot   Description = Take a snapshot of servername   Enabled = True   Scheduler =     class Once... See more...
Yes I'm sure. The output when adding that line: class ScheduledTaskSpec {   Name = Snapshot   Description = Take a snapshot of servername   Enabled = True   Scheduler =     class OnceTaskScheduler     {       RunAt =         class DateTime         {           Date = 5/4/2019 12:00:00 AM           Day = 4           DayOfWeek = Saturday           DayOfYear = 124           Hour = 17           Kind = Unspecified           Millisecond = 0           Minute = 30           Month = 5           Second = 0           Ticks = 636925878000000000           TimeOfDay = 17:30:00           Year = 2019           DateTime = Saturday, May 4, 2019 5:30:00 PM         }       ActiveTime =       ExpireTime =     }   Action =     class MethodAction     {       Name = CreateSnapshot_Task       Argument =         [           VMware.Vim.MethodActionArgument           VMware.Vim.MethodActionArgument         ]             }   Notification = <someone@somewhere.com> }
Yes, same error was received: Exception calling "CreateObjectScheduledTask" with "2" argument(s): "A specified parameter was not correct: "
I killed all of my powershell sessions, Ran the following command: Disconnect-Viserver -Server * -Force -Confirm:$false Then ran the script, and I am now getting this error on the last line: ... See more...
I killed all of my powershell sessions, Ran the following command: Disconnect-Viserver -Server * -Force -Confirm:$false Then ran the script, and I am now getting this error on the last line: Exception calling "CreateObjectScheduledTask" with "2" argument(s): "A specified parameter was not correct: "
no, same error when I take out the variable and enter a single VM name
I am trying to add some user input to the script as follows: ############### # These are the values you should get from your webform $Vcenter= Read-Host -Prompt "Which Vcenter is the machine... See more...
I am trying to add some user input to the script as follows: ############### # These are the values you should get from your webform $Vcenter= Read-Host -Prompt "Which Vcenter is the machine located on?" $vmName = Read-Host -Prompt "Snapshot of VM" $date = Read-Host -Prompt "When would you like this to be taken (DD/MM/YY 23:00 Format)" $Owner = Read-Host -Prompt "Who are you?" $requester = Read-Host -Prompt "Email Address of Requester" $SR = Read-Host -Prompt "What is the SR number?" $snapTime = Get-Date "$date" $snapName = "Snapshot of $vmName by $owner on $date per SR $SR" $snapDescription = "Snapshot of $vmName by $owner on $date Per SR $SR" $snapMemory = $false $snapQuiesce = $true $emailAddr = @("Myemailaddress@somewhere.com", "$requester") ############### #Add VMWare Snapin & connect to vcenter Add-PSSnapin VMware.VimAutomation.Core Connect-VIServer -server $Vcenter $vm = Get-VM -Name $vmName $si = get-view ServiceInstance $scheduledTaskManager = Get-View $si.Content.ScheduledTaskManager $spec = New-Object VMware.Vim.ScheduledTaskSpec $spec.Name = "Snapshot",$_.VMname -join ' ' $spec.Description = "Take a snapshot of $($vm.Name)" $spec.Enabled = $true $spec.Notification = $emailAddr $spec.Scheduler = New-Object VMware.Vim.OnceTaskScheduler $spec.Scheduler.runat = $snapTime $spec.Action = New-Object VMware.Vim.MethodAction $spec.Action.Name = "CreateSnapshot_Task" @($snapName,$snapDescription,$snapMemory,$snapQuiesce) | %{     $arg = New-Object VMware.Vim.MethodActionArgument     $arg.Value = $_     $spec.Action.Argument += $arg } $scheduledTaskManager.CreateObjectScheduledTask($vm.ExtensionData.MoRef, $spec) but I get the following error. I'm pretty new to scripting, so can someone please help me?: Cannot convert argument "obj", with value: "System.Object[]", for "CreateObjectScheduledTask" to type "VMware.Vim.ManagedObjectReference": "Cannot convert the "System.Object[]" value of type "System.Object[]" to type "VMware.Vim.ManagedObjectReference"." At \\MyServer\Folder1\Folder2\ScheduleSnapshots.ps1:43 char:1 + $scheduledTaskManager.CreateObjectScheduledTask($vm.ExtensionData.MoR ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~     + CategoryInfo          : NotSpecified: (:) [], MethodException     + FullyQualifiedErrorId : MethodArgumentConversionInvalidCastArgument