Automation

 View Only
  • 1.  NEed some help with pool refresh scheduled task using powercli

    Posted Feb 01, 2013 05:05 PM

    I am trying to set up a nightly refresh of a pool of VMs using a PS script and view CLI.

    The script is set up and working. I can run it through powercli and have it refresh the pools manually.... Where im running into issues is when i try to run the script from the actual task.

    here is the script

    Connect-VIServer vCLIENT-vcenter1.SERVER.int $a = get-date ((get-date).AddMinutes(0)) -format "yyyy-MM-%d >HH:mm" Get-Pool -pool_id TEST | Get-DesktopVM | Send-LinkedCloneRefresh -schedule $a -forcelogoff $true -stoponerror $true

    When i schedule the task i put the executable program as:

    C:\Windows\system32\windowspowershell\v1.0\powershell.exe

    Ive tired setting the paramaters to:

    -noe -c ". \"D:\Program Files\VMware\VMware View\Server\extras\PowerShell\add-snapin.ps1\"" & C:\Scripts\Nightly.Refresh.ps1

    But it times out in the scheduled tasks and hangs. I have to stop the task.

    Does anyone know what the correct parameters should be?



  • 2.  RE: NEed some help with pool refresh scheduled task using powercli

    Posted Feb 01, 2013 05:31 PM

    Are you sure the task is running with the same credentials under the Task Sceduler ?

    It could be that the execution policy used for the account under which the task runs in the scheduler is not set correctly.

    Or that account can't do SSO to the vCenter.

    Perhaps show us a screenshot of the Task Scheduler entry you created.



  • 3.  RE: NEed some help with pool refresh scheduled task using powercli

    Posted Feb 01, 2013 05:55 PM

    Here is a screen shot... started a while ago.. just hangs and no task created.



  • 4.  RE: NEed some help with pool refresh scheduled task using powercli

    Posted Feb 01, 2013 06:07 PM

    So the script was running before ?

    It is running with the same account that you used to test the script ?



  • 5.  RE: NEed some help with pool refresh scheduled task using powercli

    Posted Feb 01, 2013 06:14 PM

    how do i set the account it runs with?

    It only ran manually from within powershell cmd.



  • 6.  RE: NEed some help with pool refresh scheduled task using powercli



  • 7.  RE: NEed some help with pool refresh scheduled task using powercli

    Posted Feb 01, 2013 07:21 PM

    That post is about PowerSHell v3.

    Are you running PowerShell v3 ?

    Officially the current PowerCLI version is not supported in PowerShell v3.

    Try starting PowerShell with the '-version 2' option.

    C:\Windows\system32\windowspowershell\v1.0\powershell.exe -version 2


  • 8.  RE: NEed some help with pool refresh scheduled task using powercli

    Posted Feb 01, 2013 07:12 PM

    When you run it interactively from the PowerCLI is runs with the account you're logged on with.

    And since you don't specify a user or credential on the Connect-VIServer, that will be the account used to connect to the vSphere server.

    For a task in the Task Scheduler you can specify under which account it should run.

    The account you specify should have a working PS environment and should be able to connect to the vSphere server and executes the cmdlets from the script.



  • 9.  RE: NEed some help with pool refresh scheduled task using powercli

    Posted Mar 15, 2013 07:40 PM

    Turns out my issue was because i schdeuled the task as a local admin and not as the domain admin.

    Double check.. everything.