Connect-SqlClone failed in Powershell script

EmericEmeric Posts: 2 New member
Hi there,

When executing the command below in powershell to initiate a connection, all goes well.
  #Initiates a connection with a SQL Clone Server.
  Connect-SqlClone -Server $ServerUrl

But when initiating the same command in the middle of a script using the GUI, the script hangs. 
Placing the connection at the top of the script works, but my goal is to initiate that connection once the user will select the url from a combobox at a later stage.
Any help will be much appreciated!

#---------------------------------------------------------[Initialisations]----------------------------------------------#
# Init PowerShell Gui
Add-Type -AssemblyName System.Windows.Forms
[System.Windows.Forms.Application]::EnableVisualStyles()


#---------------------------------------------------------[Form]--------------------------------------------------------#
$SQLCloneDEForm = New-Object system.Windows.Forms.Form
$SQLCloneDEForm.ClientSize = New-Object System.Drawing.Point(400, 400)
$SQLCloneDEForm.text = "SQL Clone Sync"
$SQLCloneDEForm.TopMost = $false
$SQLCloneDEForm.BackColor = [System.Drawing.ColorTranslator]::FromHtml("#7eb1ed")

$ServerCloneLabel = New-Object system.Windows.Forms.Label
$ServerCloneLabel.text = $ServerUrl
$ServerCloneLabel.AutoSize = $true
$ServerCloneLabel.width = 25
$ServerCloneLabel.height = 10
$ServerCloneLabel.location = New-Object System.Drawing.Point(30, 50)
$ServerCloneLabel.Font = New-Object System.Drawing.Font('Calibri', 12, [System.Drawing.FontStyle]([System.Drawing.FontStyle]::Bold))


$CreateCloneBtn = New-Object system.Windows.Forms.Button
$CreateCloneBtn.BackColor = "#ff7b00"
$CreateCloneBtn.text = "Sync Clone(s)"
$CreateCloneBtn.width = 100
$CreateCloneBtn.height = 30
$CreateCloneBtn.location = New-Object System.Drawing.Point(200, 310)
$CreateCloneBtn.Font = 'Calibri,10'
$CreateCloneBtn.ForeColor = "#ffffff"
$CreateCloneBtn.Visible = $false
$SQLCloneDEForm.Controls.Add($CreateCloneBtn)

$cancelBtn = New-Object system.Windows.Forms.Button
$cancelBtn.BackColor = "#ffffff"
$cancelBtn.text = "Cancel"
$cancelBtn.width = 90
$cancelBtn.height = 30
$cancelBtn.location = New-Object System.Drawing.Point(100, 310)
$cancelBtn.Font = 'Calibri,10'
$cancelBtn.ForeColor = "#000"
$cancelBtn.DialogResult = [System.Windows.Forms.DialogResult]::Cancel
$SQLCloneDEForm.CancelButton = $cancelBtn

#Initiates a connection with a SQL Clone Server.
Connect-SqlClone -Server $ServerUrl

# Show the form
$SQLCloneDEForm.controls.AddRange(@($CreateCloneBtn, $cancelBtn, $ServerCloneLabel))
[void]$SQLCloneDEForm.ShowDialog()
Sign In or Register to comment.