Sign in
|
Join PowerShell.com!
|
Help
Home
PowerTips
Ask the Experts
Forums
Webcasts
Blogs
eBookV2
Script Library
Twitter Grid
Modules
QuickClick
Scripts
Snippets
Videos
Library
»
Script Library
»
VMware
»
DisconnectVI-Server
DisconnectVI-Server
Share
|
Browse Library
Module Library
QuickClick Library
Script Library
Active Directory
BizTalk
Citrix
Clustering
Desktop
Exchange Server 2003
Exchange Server 2007
File System
Group Policy
Internet Information Server (IIS)
Local Accounts
Logs
Microsoft Office
Microsoft Team Foundation Server
MySQL
Networking
Registry
Remote Desktop Services
Remoting
Security
SharePoint
SQL Server
System Center Virtual Machine Manager
System Center Configuration Manager
System Center Operations Manager
Tutorial
Terminal Server
Using .Net
Virtual Server
VMware
Windows 7
Windows HPC
Windows Server 2000
Windows Server 2003
Windows Server 2008
Windows XP
WMI
Misc
Snippet Library
Video Library
Members Only
Tags
Clone
Compare Clusters
Connect
Datastores
Disconnect
Disk Usage
Get-Stat
Guests
Healthcheck
Host Models
Host Version
Hosts
Load Balance
LUN
Measure-Object
Monitor
Snapshot Count
Thin-Provisioned
VI Toolkit
Virtual Disks
VM
VM List
VM's details of Data Center
VMware
vNIC
View more
Previous
|
Next
|
View all files
|
View Slideshow
Download
posted by
Richard Giles
10-06-2008
Downloads: 413
File size: 1.8kB
Views: 1,751
Embed
DisconnectVI-Server
## =====================================================================
## Title
: DisconnectVI-Server
## Description : Diswconnects from the VI server.
## Author
: Idera
## Date
: 9/11/2008
## Input
: -VIserver : Virtual Infrastructure server
##
-isDefault : true to disconnect from the last server or
false to disconnect from a specified server.
##
-verbose
##
-debug
## Output
: VMs
## Usage
: EXAMPLE 1: PS> ./DisconnectVI-Server myVIserver
false -v -d
Disconnects user from the specifed server named myVIserver
##
: EXAMPLE 2: PS> ./DisconnectVI-Server ""
true -v -d
Disconnects user from the default/last server.
## Notes
:
## Tag
: PowerShell, VMware
## =====================================================================
param
(
[
string
]
$VIserver
,
[
bool
]
$isDefault
,
[
switch
]
$verbose
,
[
switch
]
$debug
)
function
main()
{
if
(
$verbose
) {
$VerbosePreference
=
"Continue"
}
if
(
$debug
) {
$DebugPreference
=
"Continue"
}
DisconnectVI-Server
$VIserver
$isDefault
}
function
DisconnectVI-Server
([
string
]
$VIserver
=
""
, [
bool
]
$isDefault
=
$true
)
{
## Clear Screen.
Clear-Host
## Check to see if the user wants to disconnect from the defualt server if not then server specified.
## Check that there are active connections.
if
(
!
$DefaultVIServer
)
{
Write-Host
"`n`n`n`t ERROR- No VI connections found!`n`n"
-foregroundcolor
red
break
}
if
(
$isDefault
-eq
$true
)
{
## Disconnect from Default VI Server.
Disconnect-VIServer
-Server
$DefaultVIServer
}
else
{
if
(
$VIserver
-ne
""
)
{
Disconnect-VIServer
-Server
$VIserver
}
else
{
Write-Host
"`n`n`n`tERROR- A server must be specified!"
-foregroundcolor
red
}
}
}
## EOF: DisconnectVI-Server()
## Run Main
main
Filed under:
VMware
,
VI Toolkit
,
Disconnect
Disconnect from a VMware Virtual Infrastructure Server using the VI Tookkit PowerShell snapin.
Copyright 2011 PowerShell.com. All rights reserved.