Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #========================================================================
- # Tested on Powershell 5.0, PowerCli 6.3, vSphere 6.0, Windos 2003, Windows 2008, Windows 2012
- #----------------------------------------------
- #region Application Functions
- #----------------------------------------------
- function OnApplicationLoad {
- if(-not (Get-PSSnapin VMware.VimAutomation.Core)){
- Add-PSSnapin vmware.vimautomation.core -ErrorAction SilentlyContinue | Out-Null
- }
- return $true #return true for success or false for failure
- }
- function OnApplicationExit {
- if ($global:DefaultVIServers.Count -gt 0){
- Disconnect-VIServer * -Confirm:$false -ErrorAction SilentlyContinue | Out-Null
- $script:ExitCode = 0 #Set the exit code for the Packager
- }
- }
- #endregion Application Functions
- #----------------------------------------------
- # Generated Form Function
- #----------------------------------------------
- function Call-VMDiskDetails {
- #----------------------------------------------
- #region Import the Assemblies
- #----------------------------------------------
- [void][reflection.assembly]::Load("mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
- [void][reflection.assembly]::Load("System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
- [void][reflection.assembly]::Load("System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
- [void][reflection.assembly]::Load("System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
- [void][reflection.assembly]::Load("System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
- [void][reflection.assembly]::Load("System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
- [void][reflection.assembly]::Load("System.DirectoryServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
- [void][reflection.assembly]::Load("System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
- [void][reflection.assembly]::Load("System.ServiceProcess, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
- #endregion Import Assemblies
- #----------------------------------------------
- #region Generated Form Objects
- #----------------------------------------------
- [System.Windows.Forms.Application]::EnableVisualStyles()
- $FormVMDiskDetails = New-Object 'System.Windows.Forms.Form'
- $buttonListDisk = New-Object 'System.Windows.Forms.Button'
- $comboboxVMs = New-Object 'System.Windows.Forms.ComboBox'
- $labelPassword = New-Object 'System.Windows.Forms.Label'
- $labelUserName = New-Object 'System.Windows.Forms.Label'
- $labelvCDetails = New-Object 'System.Windows.Forms.Label'
- $labelGuestDetails = New-Object 'System.Windows.Forms.Label'
- $labelgPassword = New-Object 'System.Windows.Forms.Label'
- $labelgUserName = New-Object 'System.Windows.Forms.Label'
- $labelVCenterOrESXi = New-Object 'System.Windows.Forms.Label'
- $chkPassthough = New-Object 'System.Windows.Forms.CheckBox'
- $labelIncreasedDiskSize = New-Object 'System.Windows.Forms.Label'
- $labelVirtualMachines = New-Object 'System.Windows.Forms.Label'
- $txtboxIncreaseDiskSize = New-Object 'System.Windows.Forms.NumericUpDown'
- $buttonLogin = New-Object 'System.Windows.Forms.Button'
- $buttonIncrease = New-Object 'System.Windows.Forms.Button'
- $username = New-Object 'System.Windows.Forms.TextBox'
- $maskedtextbox1 = New-Object 'System.Windows.Forms.MaskedTextBox'
- $gusername = New-Object 'System.Windows.Forms.TextBox'
- $gmaskedtextbox1 = New-Object 'System.Windows.Forms.MaskedTextBox'
- $vCenterOrEsxi = New-Object 'System.Windows.Forms.TextBox'
- $InitialFormWindowState = New-Object 'System.Windows.Forms.FormWindowState'
- $dataGrid1 = New-Object System.Windows.Forms.DataGridView
- $checkBox1 = New-Object System.Windows.Forms.CheckBox
- $chkPassthough = New-Object System.Windows.Forms.CheckBox
- $chkPassthoughW = New-Object System.Windows.Forms.CheckBox
- $StatusBar = New-Object System.Windows.Forms.StatusBar
- #endregion Generated Form Objects
- #----------------------------------------------
- # User Generated Script
- #----------------------------------------------
- function OnApplicationLoad {
- Add-PSSnapin VMware.VimAutomation.Cloud
- Add-PSSnapin vmware.vimautomation.core
- return $true #return true for success or false for failure
- }
- function OnApplicationExit {
- Disconnect-VIServer * -Confirm:$false
- $script:ExitCode = 0 #Set the exit code for the Packager
- }
- $FormVMDiskDetails_Load={
- #TODO: Initialize Form Controls here
- }
- #region Control Helper Functions
- function Load-ComboBox
- {
- Param (
- [ValidateNotNull()]
- [Parameter(Mandatory=$true)]
- [System.Windows.Forms.ComboBox]$ComboBox,
- [ValidateNotNull()]
- [Parameter(Mandatory=$true)]
- $Items,
- [Parameter(Mandatory=$false)]
- [string]$DisplayMember,
- [switch]$Append
- )
- if(-not $Append)
- {
- $ComboBox.Items.Clear()
- }
- if($Items -is [Object[]])
- {
- $ComboBox.Items.AddRange($Items)
- }
- elseif ($Items -is [Array])
- {
- $ComboBox.BeginUpdate()
- foreach($obj in $Items)
- {
- $ComboBox.Items.Add($obj)
- }
- $ComboBox.EndUpdate()
- }
- else
- {
- $ComboBox.Items.Add($Items)
- }
- $ComboBox.DisplayMember = $DisplayMember
- }
- function IsThereText
- {
- if ($vCenterOrEsxi.Text.Length -ne 0)
- {
- $buttonLogin.Enabled = $true
- }
- else
- {
- $buttonLogin.Enabled = $false
- }
- }
- #endregion
- $picturebox1_Click={
- #TODO: Place custom script here
- }
- $chkPassthough_Click={
- if ($chkPassthough.Checked)
- {
- $username.Text = whoami
- $username.Enabled = $false
- $maskedtextbox1.Enabled = $false
- }
- else
- {
- $username.Enabled = $true
- $maskedtextbox1.Enabled = $true
- }
- }
- $chkPassthoughW_Click={
- if ($chkPassthoughW.Checked)
- {
- $gusername.Text = whoami
- $gusername.Enabled = $false
- $gmaskedtextbox1.Enabled = $false
- }
- else
- {
- $gusername.Enabled = $true
- $gmaskedtextbox1.Enabled = $true
- }
- }
- $buttonLogin_Click={
- #TODO: Place custom script here
- if ($vCenterOrEsxi.TextLength -ne 0)
- {
- Try {
- $vCenterOrESXiName = $vCenterOrEsxi.Text
- $StatusBar.Text = "Connecting $vCenterOrESXiName..."
- if ($chkPassthough.Checked)
- {
- Connect-VIServer $vCenterOrEsxi.Text -ErrorAction SilentlyContinue | Out-Null
- $StatusBar.Text = "Connected $vCenterOrESXiName via Passthrough..."
- }
- else
- {
- Connect-VIServer $vCenterOrEsxi.Text -User $username.Text -Password $maskedtextbox1.Text -ErrorAction SilentlyContinue | Out-Null
- $StatusBar.Text = "Connected $vCenterOrESXiName with defined credentials..."
- }
- $VMs = Get-VM | Select-Object -ExpandProperty Name
- $VMs | ForEach-Object {Load-ComboBox -ComboBox $ComboBoxVMs -Append -Items $_}
- $comboboxVMs.Enabled = $true
- $buttonListDisk.Enabled = $true
- }
- Catch {
- $error[0].Exception | Out-Null
- $StatusBar.Text = "Unable to connect $vCenterOrESXiName, validate details and connectivity..."
- $comboboxVMs.Enabled = $false
- $buttonIncrease.Enabled = $false
- }
- }
- }
- $comboboxVMs_SelectedIndexChanged={
- #TODO: Place custom script here
- }
- $dataGrid1_Click={
- $txtboxIncreaseDiskSize.Value = $dataGrid1.CurrentRow.Cells[4].Value
- if ($dataGrid1.CurrentRow.Cells[7].Value -eq "C:"){
- $checkBox1.Checked = $true
- }else {
- $checkBox1.Checked = $false
- }
- }
- $buttonIncrease_Click={
- if($txtboxIncreaseDiskSize.Value -gt $dataGrid1.CurrentRow.Cells[4].Value){
- Get-HardDisk -vm $ComboBoxVMs.SelectedItem.ToString() | where {$_.Name -eq $dataGrid1.CurrentRow.Cells[3].Value} | Set-HardDisk -CapacityGB $txtboxIncreaseDiskSize.Text -ResizeGuestPartition -GuestUser $gusername.Text -GuestPassword $gmaskedtextbox1.Text -Confirm:$false
- }
- }
- $buttonListDisk_Click={
- #TODO: Place custom script here
- $dataGrid1.Rows.Clear()
- $dataGrid1.Refresh()
- if($($ComboBoxVMs.SelectedItem.ToString() | measure).count){
- $gpassword = $gmaskedtextbox1.Text | ConvertTo-SecureString -AsPlainText -Force
- $GuestCredentials = new-object system.management.automation.PSCredential $gusername.Text,$gpassword
- #===
- #Change this as needed. Our standard display name is the hostname followed by a space...
- $VMView = Get-VM -Name $ComboBoxVMs.SelectedItem.ToString() | Get-View
- $ServerDiskToVolume = @(
- Get-WmiObject -Class Win32_DiskDrive -ComputerName $VMView.Name -Credential $GuestCredentials | foreach {
- $Dsk = $_
- $query = "ASSOCIATORS OF {Win32_DiskDrive.DeviceID='$($_.DeviceID)'} WHERE ResultClass=Win32_DiskPartition"
- Get-WmiObject -Query $query -ComputerName $VMView.Name -Credential $GuestCredentials | foreach {
- $query = "ASSOCIATORS OF {Win32_DiskPartition.DeviceID='$($_.DeviceID)'} WHERE ResultClass=Win32_LogicalDisk"
- Get-WmiObject -Query $query -ComputerName $VMView.Name -Credential $GuestCredentials | Select DeviceID,
- VolumeName,
- @{ label = "SCSITarget"; expression = {$dsk.SCSITargetId} },
- @{ label = "SCSIBus"; expression = {$dsk.SCSIBus} }
- }
- }
- )
- # Now loop thru all the SCSI controllers on the VM and find those that match the Controller and Target
- $VMDisks = ForEach ($VirtualSCSIController in ($VMView.Config.Hardware.Device | Where {$_.DeviceInfo.Label -match "SCSI Controller"}))
- {
- ForEach ($VirtualDiskDevice in ($VMView.Config.Hardware.Device | Where {$_.ControllerKey -eq $VirtualSCSIController.Key}))
- {
- #Match up this VM to a logical disk
- $MatchingDisk = @( $ServerDiskToVolume | Where {$_.SCSITarget -eq $VirtualDiskDevice.UnitNumber -and $_.SCSIBus -eq $VirtualSCSIController.BusNumber} )
- $DiskFileName = $VirtualDiskDevice.Backing.FileName
- $DSName = $DiskFileName.Split("]")[0].TrimStart("[")
- #Build a custom object to hold this. We use PS3 language...
- [pscustomobject]@{
- VMName = $VMView.Name
- HostName = $VMView.Guest.HostName
- PowerStatus = $VMView.Runtime.PowerState
- DiskFile = $VirtualDiskDevice.Backing.FileName
- DiskName = $VirtualDiskDevice.DeviceInfo.Label
- DiskSize = $VirtualDiskDevice.CapacityInKB / 1MB
- SCSIController = $VirtualSCSIController.BusNumber
- SCSITarget = $VirtualDiskDevice.UnitNumber
- DeviceID = $MatchingDisk.DeviceID
- DSFreeGB = Get-Datastore -Name $DSName | %{$_.FreeSpaceGB}
- }
- }
- }
- $VMDisks | foreach{$datagrid1.Rows.Add($_.VMName,$_.HostName,$_.PowerStatus,$_.DiskFile,$_.DiskName,$_.DiskSize,$_.SCSIController,$_.SCSITarget,$_.DeviceID,"{0:N2}" -f $_.DSFreeGB)}
- #
- #===
- $dataGrid1.AutoResizeColumns()
- $txtboxIncreaseDiskSize.Value = $dataGrid1.CurrentRow.Cells[4].Value
- if ($dataGrid1.CurrentRow.Cells[7].Value -eq "C:"){
- $checkBox1.Checked = $true
- }else {
- $checkBox1.Checked = $false
- }
- }
- $txtboxIncreaseDiskSize.Enabled = $true
- $buttonIncrease.Enabled = $true
- }
- $labelMessage_Click={
- #TODO: Place custom script here
- }
- # --End User Generated Script--
- #----------------------------------------------
- #region Generated Events
- #----------------------------------------------
- $Form_StateCorrection_Load=
- {
- #Correct the initial state of the form to prevent the .Net maximized form issue
- $FormVMDiskDetails.WindowState = $InitialFormWindowState
- }
- $Form_Cleanup_FormClosed=
- {
- #Remove all event handlers from the controls
- try
- {
- $buttonListDisk.remove_Click($buttonListDisk_Click)
- $comboboxVMs.remove_SelectedIndexChanged($comboboxVMs_SelectedIndexChanged)
- $buttonLogin.remove_Click($buttonLogin_Click)
- $FormVMDiskDetails.remove_Load($FormVMDiskDetails_Load)
- $FormVMDiskDetails.remove_Load($Form_StateCorrection_Load)
- $FormVMDiskDetails.remove_FormClosed($Form_Cleanup_FormClosed)
- }
- catch [Exception]
- { }
- }
- #endregion Generated Events
- #----------------------------------------------
- #region Generated Form Code
- #----------------------------------------------
- #
- # FormDiskIncrease
- #
- $FormVMDiskDetails.Controls.Add($buttonListDisk)
- $FormVMDiskDetails.Controls.Add($comboboxVMs)
- $FormVMDiskDetails.Controls.Add($labelPassword)
- $FormVMDiskDetails.Controls.Add($labelUserName)
- $FormVMDiskDetails.Controls.Add($labelgPassword)
- $FormVMDiskDetails.Controls.Add($labelgUserName)
- $FormVMDiskDetails.Controls.Add($labelVCenterOrESXi)
- $FormVMDiskDetails.Controls.Add($buttonLogin)
- $FormVMDiskDetails.Controls.Add($buttonIncrease)
- $FormVMDiskDetails.Controls.Add($username)
- $FormVMDiskDetails.Controls.Add($maskedtextbox1)
- $FormVMDiskDetails.Controls.Add($gusername)
- $FormVMDiskDetails.Controls.Add($gmaskedtextbox1)
- $FormVMDiskDetails.Controls.Add($labelIncreasedDiskSize)
- $FormVMDiskDetails.Controls.Add($labelVirtualMachines)
- $FormVMDiskDetails.Controls.Add($txtboxIncreaseDiskSize)
- $FormVMDiskDetails.Controls.Add($vCenterOrEsxi)
- $FormVMDiskDetails.Controls.Add($dataGrid1)
- $FormVMDiskDetails.Controls.Add($checkBox1)
- $FormVMDiskDetails.Controls.Add($chkPassthough)
- $FormVMDiskDetails.Controls.Add($chkPassthoughW)
- $FormVMDiskDetails.Controls.Add($StatusBar)
- $FormVMDiskDetails.Controls.Add($labelvCDetails)
- $FormVMDiskDetails.Controls.Add($labelGuestDetails)
- $FormVMDiskDetails.ClientSize = '1100, 700'
- #
- $FormVMDiskDetails.Name = "FormDiskIncrease"
- $FormVMDiskDetails.StartPosition = "CenterScreen"
- $FormVMDiskDetails.AutoSizeMode = "GrowOnly"
- $FormVMDiskDetails.Text = "Virtual Machine Disk Increase - By Sudarshan Bharti"
- $FormVMDiskDetails.add_Load($FormVMDiskDetails_Load)
- #
- # buttonListDisk
- #
- $buttonListDisk.Location = '362, 148'
- $buttonListDisk.Name = "buttonListDisk"
- $buttonListDisk.Size = '90, 23'
- $buttonListDisk.TabIndex = 14
- $buttonListDisk.Enabled = $false
- $buttonListDisk.Text = "List &Disks"
- $buttonListDisk.UseVisualStyleBackColor = $True
- $buttonListDisk.add_Click($buttonListDisk_Click)
- #
- # StatusBar
- #
- $StatusBar.Name = "StatusBar"
- $StatusBar.Size = '95, 23'
- $StatusBar.TabIndex = 20
- $StatusBar.Text = "Enter vCenter and Credentials..."
- $StatusBar.ShowPanels = $false
- #
- # buttonIncrease
- #
- $buttonIncrease.Location = '692, 148'
- $buttonIncrease.Name = "buttonIncrease"
- $buttonIncrease.Size = '90, 23'
- $buttonIncrease.TabIndex = 18
- $buttonIncrease.Enabled = $false
- $buttonIncrease.Text = "&IncreaseDisk"
- $buttonIncrease.UseVisualStyleBackColor = $True
- $buttonIncrease.add_Click($buttonIncrease_Click)
- #
- # comboboxVMs
- #
- $comboboxVMs.FormattingEnabled = $True
- $comboboxVMs.Location = '13, 148'
- $comboboxVMs.Name = "comboboxVMs"
- $comboboxVMs.Size = '318, 23'
- $comboboxVMs.TabIndex = 13
- $comboboxVMs.Enabled = $false
- $comboboxVMs.add_SelectedIndexChanged($comboboxVMs_SelectedIndexChanged)
- #
- # labelPassword
- #
- $labelPassword.Location = '12, 91'
- $labelPassword.Name = "labelPassword"
- $labelPassword.Size = '100, 23'
- $labelPassword.TabIndex = 6
- $labelPassword.Text = "&Password"
- #
- # labelUserName
- #
- $labelUserName.Location = '12, 65'
- $labelUserName.Name = "labelUserName"
- $labelUserName.Size = '100, 23'
- $labelUserName.TabIndex = 4
- $labelUserName.Text = "&UserName"
- #
- # labelvCDetails
- #
- $labelvCDetails.Location = '90, 10'
- $labelvCDetails.Name = "labelvCDetails"
- $labelvCDetails.Size = '250, 23'
- $labelvCDetails.TabIndex = 13
- $labelvCDetails.Text = "&vCenter Details"
- $labelvCDetails.Font = New-Object System.Drawing.Font("Arial",12,[System.Drawing.FontStyle]::Bold)
- #
- # labelGuestDetails
- #
- $labelGuestDetails.Location = '662, 10'
- $labelGuestDetails.Name = "labelGuestDetails"
- $labelGuestDetails.Size = '250, 23'
- $labelGuestDetails.TabIndex = 13
- $labelGuestDetails.Text = "Guest &Credentials"
- $labelGuestDetails.Font = New-Object System.Drawing.Font("Arial",12,[System.Drawing.FontStyle]::Bold)
- #
- # labelgPassword
- #
- $labelgPassword.Location = '562, 65'
- $labelgPassword.Name = "labelgPassword"
- $labelgPassword.Size = '100, 23'
- $labelgPassword.TabIndex = 14
- $labelgPassword.Text = "&Guest Password"
- #
- # labelgUserName
- #
- $labelgUserName.Location = '562, 39'
- $labelgUserName.Name = "labelgUserName"
- $labelgUserName.Size = '100, 23'
- $labelgUserName.TabIndex = 14
- $labelgUserName.Text = "Gu&est UserName"
- #
- # labelIncreasedDiskSize
- #
- $labelIncreasedDiskSize.Location = '562, 125'
- $labelIncreasedDiskSize.Name = "labelIncreasedDiskSize"
- $labelIncreasedDiskSize.Size = '130, 23'
- $labelIncreasedDiskSize.TabIndex = 16
- $labelIncreasedDiskSize.Text = "I&ncreased Disk Size"
- #
- # labelVirtualMachine
- #
- $labelVirtualMachines.Location = '12, 125'
- $labelVirtualMachines.Name = "labelVirtualMachine"
- $labelVirtualMachines.Size = '100, 23'
- $labelVirtualMachines.TabIndex = 12
- $labelVirtualMachines.Text = "Virtual &Machines"
- #
- # txtboxIncreaseDiskSize
- #
- $txtboxIncreaseDiskSize.Location = '565, 148'
- $txtboxIncreaseDiskSize.Name = "txtboxIncreaseDiskSize"
- $txtboxIncreaseDiskSize.Size = '60, 23'
- $txtboxIncreaseDiskSize.TabIndex = 17
- $txtboxIncreaseDiskSize.Increment = 1
- $txtboxIncreaseDiskSize.Enabled = $false
- $txtboxIncreaseDiskSize.Maximum = 2048
- $txtboxIncreaseDiskSize.Minimum = 1
- #
- # labelVCenterOrESXi
- #
- $labelVCenterOrESXi.Location = '12, 39'
- $labelVCenterOrESXi.Name = "labelVCenterOrESXi"
- $labelVCenterOrESXi.Size = '100, 23'
- $labelVCenterOrESXi.TabIndex = 1
- $labelVCenterOrESXi.Text = "&vCenter or ESXi"
- #
- # buttonLogin
- #
- $buttonLogin.Location = '892, 91'
- $buttonLogin.Name = "buttonLogin"
- $buttonLogin.Size = '89, 23'
- $buttonLogin.TabIndex = 11
- $buttonLogin.Text = "&Login"
- $buttonLogin.Enabled = $false
- $buttonLogin.UseVisualStyleBackColor = $True
- $buttonLogin.add_Click($buttonLogin_Click)
- #
- # username
- #
- $username.Location = '127, 65'
- $username.Name = "username"
- $username.Size = '204, 23'
- $username.TabIndex = 5
- $username.Text = whoami
- $username.Enabled = $false
- $maskedtextbox1.Enabled = $false
- #
- # maskedtextbox1
- #
- $maskedtextbox1.Location = '127, 91'
- $maskedtextbox1.Name = "maskedtextbox1"
- $maskedtextbox1.Size = '204, 23'
- $maskedtextbox1.TabIndex = 7
- $maskedtextbox1.UseSystemPasswordChar = $True
- #
- # gusername
- #
- $gusername.Location = '662, 39'
- $gusername.Name = "username"
- $gusername.Size = '204, 23'
- $gusername.TabIndex = 9
- $gusername.Text = whoami
- $gusername.Enabled = $false
- $gmaskedtextbox1.Enabled = $false
- #
- # gmaskedtextbox1
- #
- $gmaskedtextbox1.Location = '662, 65'
- $gmaskedtextbox1.Name = "maskedtextbox1"
- $gmaskedtextbox1.Size = '204, 23'
- $gmaskedtextbox1.TabIndex = 10
- $gmaskedtextbox1.UseSystemPasswordChar = $True
- #
- # vCenterOrEsxi
- #
- $vCenterOrEsxi.Location = '127, 39'
- $vCenterOrEsxi.Name = "&vCenterOrEsxi"
- $vCenterOrEsxi.Size = '204, 23'
- $vCenterOrEsxi.TabIndex = 2
- $vCenterOrEsxi.add_TextChanged({IsThereText})
- #
- # dataGrid1
- #
- $dataGrid1.Location = '13, 180'
- $dataGrid1.Name = "dataGrid1"
- $dataGrid1.Size = '1070, 497'
- $dataGrid1.TabIndex = 15
- $dataGrid1.MultiSelect = $false
- $dataGrid1.SelectionMode = 'FullRowSelect'
- $dataGrid1.AllowUserToAddRows = $false
- $dataGrid1.AllowUserToDeleteRows = $false
- $dataGrid1.AllowUserToOrderColumns = $true
- $dataGrid1.ReadOnly = $true
- $dataGrid1.AllowUserToResizeColumns = $false
- $dataGrid1.AllowUserToResizeRows = $false;
- $dataGrid1.ColumnCount = 10
- $dataGrid1.ColumnHeadersVisible = $true
- $dataGrid1.Columns[0].Name = "VMName"
- $dataGrid1.Columns[1].Name = "HostName"
- $dataGrid1.Columns[2].Name = "PowerStatus"
- $dataGrid1.Columns[3].Name = "DiskFile"
- $dataGrid1.Columns[4].Name = "DiskName"
- $dataGrid1.Columns[5].Name = "DiskSize"
- $dataGrid1.Columns[6].Name = "SCSIController"
- $dataGrid1.Columns[7].Name = "SCSITarget"
- $dataGrid1.Columns[8].Name = "DeviceID"
- $dataGrid1.Columns[9].Name = "DSFreeGB"
- $dataGrid1.add_Click($dataGrid1_Click)
- #
- # checkBox1
- #
- $checkBox1.Location = '990, 148'
- $checkBox1.Name = "checkBox1"
- $checkBox1.Size = '204, 23'
- $checkBox1.TabIndex = 18
- $checkBox1.Text = "System Partition"
- $checkBox1.Enabled = $false
- #
- # chkPassthough
- #
- $chkPassthough.Location = '360, 39'
- $chkPassthough.Name = "chkPassthough"
- $chkPassthough.Text = "&Use Windows Login"
- $chkPassthough.TabIndex = 3
- $chkPassthough.Size = '200, 23'
- $chkPassthough.UseVisualStyleBackColor = $True
- $chkPassthough.Checked = $True
- $chkPassthough.add_Click($chkPassthough_Click)
- #
- # chkPassthoughW
- #
- $chkPassthoughW.Location = '892, 39'
- $chkPassthoughW.Name = "chkPassthoughW"
- $chkPassthoughW.Text = "Use &Windows Login"
- $chkPassthoughW.TabIndex = 8
- $chkPassthoughW.Size = '200, 23'
- $chkPassthoughW.UseVisualStyleBackColor = $True
- $chkPassthoughW.Checked = $True
- $chkPassthoughW.add_Click($chkPassthoughW_Click)
- #endregion Generated Form Code
- #----------------------------------------------
- #Save the initial state of the form
- $InitialFormWindowState = $FormVMDiskDetails.WindowState
- #Init the OnLoad event to correct the initial state of the form
- $FormVMDiskDetails.add_Load($Form_StateCorrection_Load)
- #Clean up the control events
- $FormVMDiskDetails.add_FormClosed($Form_Cleanup_FormClosed)
- #Show the Form
- return $FormVMDiskDetails.ShowDialog()
- } #End Function
- #Call OnApplicationLoad to initialize
- if((OnApplicationLoad) -eq $true)
- {
- #Call the form
- Call-VMDiskDetails | Out-Null
- #Perform cleanup
- OnApplicationExit
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement