Altiris Software Dev Kit (ASDK)

 View Only
  • 1.  Exiting VMware vSphere PowerCLI command prompt?

    Posted Aug 30, 2017 07:33 AM

    Is there a content to contribution to exit VMware vSphere PowerCLI order provoke subsequent to executing an arrangement of content for instance made of VM.

    MY last line of my .ps1 content is demonstrated as follows, however the exit does not work, in the wake of executing my content, the order incite is still there, dissimilar to windows summon fast as the leave charge works yet not in powercli.

     

    New-VM -name $vm  -DiskMB 10000 -memoryMB 4000
    New-CDDrive -VM $vm -ISOPath  $win7 -StartConnected:$true -Confirm:$false
    $scsiController = Get-HardDisk -VM $vm | Select -First 1 | Get-ScsiController
    Set-ScsiController -ScsiController $scsiController -Type VirtualLsiLogicSAS -Confirm:$false
    
    Start-VM -vm $vm
    Exit

    Thank You



  • 2.  RE: Exiting VMware vSphere PowerCLI command prompt?

    Posted Aug 31, 2017 04:10 AM

    Have you had any luck on the vsphere Community?

    https://communities.vmware.com/community/vmtn/vsphere

     

    VMware PowerCLI Documentation
    https://www.vmware.com/support/developer/PowerCLI/

    VMware vSphere PowerCLI Cmdlets Reference
    https://www.vmware.com/support/developer/windowstoolkit/wintk40u1/html/index.html



  • 3.  RE: Exiting VMware vSphere PowerCLI command prompt?

    Posted Sep 04, 2017 10:30 AM

    Have you tried adding an exit code to the exit command?

    Like this:

    param(
    	[string] $Server,
    	[string] $Protocol,
    	[string] $User,
    	[string] $Password
    )
    
    $env:PSModulePath = $env:PSModulePath + ";C:\Users\Administrator\Documents\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules\;C:\Program Files (x86)\VMware\Infrastructure\PowerCLI\Modules"
    
    # Source VMware PowerCLI Environment
    . "C:\Program Files (x86)\VMware\Infrastructure\PowerCLI\Scripts\SPCC_Initialize-PowerCLIEnvironment.ps1" 1> $null
    
    # Execute code
    Connect-VIServer -Server $Server -Protocol $Protocol -User $User -Password $Password -WarningAction SilentlyContinue 1> $null 
    if ( $? -eq $True ) {
    	Get-VM | Format-Table -HideTableHeaders -AutoSize Name 
    	Disconnect-VIServer -Server $Server -Confirm:$False; 1> $null
    	exit 0
    } else {
    	exit 1
    }