diff --git a/MainForm.ps1 b/MainForm.ps1 index 5a23649..7f11b6e 100644 --- a/MainForm.ps1 +++ b/MainForm.ps1 @@ -77,13 +77,25 @@ $btnSaveConfig.Add_Click({ -TempLibrary $txtTempLib.Text }) +# Add Connect button +$btnConnect = New-Object System.Windows.Forms.Button +$btnConnect.Location = New-Object System.Drawing.Point(320,40) +$btnConnect.Size = New-Object System.Drawing.Size(80,20) +$btnConnect.Text = "Connect" +$btnConnect.Add_Click({ + if (Connect-SharePoint) { + $script:txtStatus.Text += "Successfully connected to SharePoint`n" + } +}) + $form.Controls.AddRange(@( $txtSiteUrl, $txtProdLib, $txtTempLib, $txtFolder, $btnBrowse, - $btnSaveConfig + $btnSaveConfig, + $btnConnect )) # Load configuration diff --git a/SharePointFunctions.ps1 b/SharePointFunctions.ps1 index 7772723..739d929 100644 --- a/SharePointFunctions.ps1 +++ b/SharePointFunctions.ps1 @@ -130,10 +130,6 @@ function Move-Files { } function Get-FolderBrowser { try { - if (-not (Connect-SharePoint)) { - return $null - } - # Verify library exists and is accessible $library = Get-PnPList -Identity $script:txtProdLib.Text -Includes RootFolder,HasUniqueRoleAssignments if ($library.HasUniqueRoleAssignments) {