ConnectVI-Server


posted by Richard Giles
10-06-2008

Downloads: 387
File size: 1.6kB
Views: 1,480

Embed
ConnectVI-Server
  1. ## ===================================================================== 
  2. ## Title       : ConnectVI-Server 
  3. ## Description : Connects to the VI server. 
  4. ## Author      : Idera 
  5. ## Date        : 9/11/2008 
  6. ## Input       : -VIserver : Virtual Infrastructure server 
  7. ##               -verbose 
  8. ##               -debug    
  9. ## Output      :  
  10. ## Usage       : EXAMPLE 1: PS> ./ConnectVI-Server myVIserver  -v -d   Connects to VI server named myVIserver. 
  11. ## Notes       :  
  12. ## Tag         : PowerShell, VMware 
  13. ## ===================================================================== 
  14.  
  15. param 
  16.    [string]$VIserver
  17.    [switch]$verbose
  18.    [switch]$debug 
  19.  
  20. function main() 
  21.    if ($verbose) {$VerbosePreference = "Continue"
  22.    if ($debug) {$DebugPreference = "Continue"
  23.    ConnectVI-Server $VIserver  
  24.  
  25. function ConnectVI-Server([string]$VIserver = ""
  26.     ## Clear Screen. 
  27.     Clear-Host 
  28.      
  29.     ## Warn user they must be logged on with an account that has connection rights to the VI server. 
  30.     $answer = Read-Host "`n`n`n`tNOTE: You must be logged on with an account that has connection rights to the VI server. Press <X> to exit or <Enter> to continue. " 
  31.     if($answer -eq "x"
  32.     
  33.         break     
  34.     
  35.     else 
  36.     
  37.         if($VIserver -eq ""
  38.         
  39.             Write-Host "`n`n`n`tERROR- A VI server must be specified!`n`n" -foregroundcolor red 
  40.             break 
  41.         
  42.         else 
  43.         
  44.             Connect-VIServer $VIserver 
  45.             Write-Host "`n`n`t You have connected to Server: $VIserver.Name with a SessionID of: $VIserver.SessionID ." 
  46.             Read-Host "`n`t Press <Enter> to continue " 
  47.         
  48.     
  49. } ## EOF: ConnectVI-Server() 
  50.  
  51. ## Run Main 
  52. main 
Filed under: , ,

Connects to a VMware Infrastructure Server using the VMware VI Tools PowerShell snapin.

Concentrated Tech NSoftware Dell Compellent Sponsored by Idera and Concentrated Tech and NSoftware and Dell Compellent
Copyright 2011 PowerShell.com. All rights reserved.