I need some help. I am creating a form that emurates all the drives with some input boxes so items can be change such as lables. It disaplys on the form correctly looks nice but I have don't have any idea how to get repeaded data like that on a form into an array so that I can reconfigure the drives. Any sugestions would be great.
I did find out that adding "$objArray += $objDriveLetter" at the end seems to capture the input boxes but it is not in a useful format.
Function DiskDrives{
$RowSize = 100
$RowSize = 0
$global:i = 0
$Drives = @("C","D","L","I","T","U")
$DriveLabels = @("","DATA","LOGS","INSTANCE","TEMP","BACKUP")
$objArray = @()
$x = @()
$global:QUIT = $false
#Get Drives
$Disks = get-disk | sort Number
Add-Type -AssemblyName System.Windows.Forms
$Form = New-Object system.Windows.Forms.Form
$Form.Text = "Drive layout Specs"
$Form.Size = New-Object System.Drawing.Size(350,350)
$Font = New-Object System.Drawing.Font("Times New Roman",12,[System.Drawing.FontStyle]::Italic)
# Font styles are: Regular, Bold, Italic, Underline, Strikeout
$Form.Font = $Font
#Title
$Label = New-Object System.Windows.Forms.Label
$Label.Text = "Number Letter Label Size"
$Label.AutoSize = $True
Foreach($Disk in $Disks){
$global:i += 1
$RowSize += 30
#Add Drive Number box
$DriveNum = New-Object System.Windows.Forms.Label
$DriveNum.Location = New-Object System.Drawing.Size(30,$RowSize)
$DriveNum.Text = $Disk.Number
$DriveNum.AutoSize = $True
$Form.Controls.Add($DriveNum)
$objArray += $DriveNum
#Add Drive letter box
$objDriveLetter = New-Object System.Windows.Forms.TextBox
$objDriveLetter.Location = New-Object System.Drawing.Size(80,$RowSize)
$objDriveLetter.Size = New-Object System.Drawing.Size(30,20)
$objDriveLetter.Text = $Drives[$global:i-1]
$Form.Controls.Add($objDriveLetter)
$Form.Topmost = $True
$objArray += $objDriveLetter
#Add Drive Label
$objDriveLabel = New-Object System.Windows.Forms.TextBox
$objDriveLabel.Location = New-Object System.Drawing.Size(120,$RowSize)
$objDriveLabel.Size = New-Object System.Drawing.Size(90,20)
$objDriveLabel.Text = $DriveLabels[$global:i-1]
$Form.Controls.Add($objDriveLabel)
$Form.Topmost = $True
$objArray += $objDriveLabel
#Add Drive Size
$DriveSize = New-Object System.Windows.Forms.Label
$DriveSize.Location = New-Object System.Drawing.Size(235,$RowSize)
$DriveSize.Text = $Disk.Size / 1GB
$Form.Controls.Add($DriveSize)
$objArray += $DriveSize
}
$RowSize += 50
$SubmitButton = New-Object System.Windows.Forms.Button
$SubmitButton.Location = New-Object System.Drawing.Size(60,$RowSize)
$SubmitButton.Size = New-Object System.Drawing.Size(75,23)
$SubmitButton.Text = "Submit"
$SubmitButton.Add_Click({$Form.Close()})
$Form.Controls.Add($SubmitButton)
$CancelButton = New-Object System.Windows.Forms.Button
$CancelButton.Location = New-Object System.Drawing.Size(150,$RowSize)
$CancelButton.Size = New-Object System.Drawing.Size(75,23)
$CancelButton.Text = "Cancel"
$CancelButton.Add_Click({$global:QUIT = $true;$Form.Close()})
$Form.Controls.Add($CancelButton)
Form.Controls.Add($Label)
$Form.ShowDialog()
if($global:QUIT -eq $true){Exit}
}