Skip to content

Instantly share code, notes, and snippets.

@gowatana
Last active August 10, 2017 03:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gowatana/0dfab57feb0598452bccf2448c45f4d9 to your computer and use it in GitHub Desktop.
Save gowatana/0dfab57feb0598452bccf2448c45f4d9 to your computer and use it in GitHub Desktop.
$module_list = @(
"VMware.VimAutomation.Core",
"VMware.VimAutomation.Vds",
"PowerNSX"
)
Import-Module $module_list
$window_width = 120
$window_height = 40
$window_buffer = 3000
$pshost = Get-Host
$pswindow = $pshost.ui.rawui
$pswindow.WindowTitle = "PowerNSX"
$newsize = $pswindow.buffersize
$newsize.height = $window_buffer
$newsize.width = $window_width
$pswindow.buffersize = $newsize
$newsize = $pswindow.windowsize
$newsize.height = $window_height
$newsize.width = $window_width
$pswindow.windowsize = $newsize
Clear-Host
$module = Get-Module -Name PowerNSX
Write-Host ""
Write-Host "Welcome to " -NoNewLine
Write-Host $module.Name -foregroundcolor Cyan
Write-Host $module.ProjectUri
Write-Host ""
Write-Host $module.Copyright
Write-Host ""
Write-Host $module.Description
Write-Host ""
(Get-Module $module_list | ft -AutoSize Name,Version -HideTableHeaders | Out-String).trim()
Write-Host ""
Write-Host "Log in to a vCenter Server and NSX Mnager: "
Write-Host " Connect-NsxServer -vCenterServer <vCenter Server>" -foregroundcolor yellow
Write-Host ""
function prompt{
$vc = $global:DefaultVIServer
$nsx = $DefaultNSXConnection
if(($vc.IsConnected -eq $True) -and ($nsx.Server -ne $null)){
$prompt_color = "Cyan"
if($vc.Name -ne $nsx.VIConnection){
$prompt_color = "Red"
}
}
elseif(($vc.IsConnected -ne $True) -and ($nsx.Server -ne $null)){
$prompt_color = "DarkCyan"
}
elseif(($vc.IsConnected -eq $True) -and ($nsx.Server -eq $null)){
$prompt_color = "Green"
}
else{
$prompt_color = "Gray"
}
Write-Host "PowerNSX" -NoNewLine -ForegroundColor $prompt_color
Write-Host ">" -NoNewline
return " "
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment