Added stuff

This commit is contained in:
Sébastien QUEROL 2024-03-11 23:58:54 +01:00
parent 8b50ddb79c
commit 993825bea5
1 changed files with 59 additions and 25 deletions

View File

@ -32,6 +32,7 @@ $Mquestion = New-Object System.Windows.Forms.ToolStripMenuItem
$MQuestionApropos = New-Object System.Windows.Forms.ToolStripMenuItem $MQuestionApropos = New-Object System.Windows.Forms.ToolStripMenuItem
$MQuestionWiki = New-Object System.Windows.Forms.ToolStripMenuItem $MQuestionWiki = New-Object System.Windows.Forms.ToolStripMenuItem
$Bgo = New-Object System.Windows.Forms.Button $Bgo = New-Object System.Windows.Forms.Button
$BlistSites = New-Object System.Windows.Forms.Button
$CBsourceSite = New-Object System.Windows.Forms.ComboBox $CBsourceSite = New-Object System.Windows.Forms.ComboBox
$CBdestSite = New-Object System.Windows.Forms.ComboBox $CBdestSite = New-Object System.Windows.Forms.ComboBox
$progressBar1 = New-Object System.Windows.Forms.ProgressBar $progressBar1 = New-Object System.Windows.Forms.ProgressBar
@ -98,13 +99,23 @@ $Bgo.TabIndex = 1
$Bgo.Text = "GO" $Bgo.Text = "GO"
$Bgo.UseVisualStyleBackColor = $true $Bgo.UseVisualStyleBackColor = $true
# #
# BlistSites
#
$BlistSItes.ForeColor = [System.Drawing.Color]::Black
$BlistSItes.Location = New-Object System.Drawing.Point(649, 55)
$BlistSItes.Name = "BlistSites"
$BlistSItes.Size = New-Object System.Drawing.Size(75, 23)
$BlistSItes.TabIndex = 2
$BlistSItes.Text = "List. Sites"
$BlistSItes.UseVisualStyleBackColor = $true
#
# CBsourceSite # CBsourceSite
# #
$CBsourceSite.FormattingEnabled = $true $CBsourceSite.FormattingEnabled = $true
$CBsourceSite.Location = New-Object System.Drawing.Point(23, 44) $CBsourceSite.Location = New-Object System.Drawing.Point(23, 44)
$CBsourceSite.Name = "CBsourceSite" $CBsourceSite.Name = "CBsourceSite"
$CBsourceSite.Size = New-Object System.Drawing.Size(587, 21) $CBsourceSite.Size = New-Object System.Drawing.Size(587, 21)
$CBsourceSite.TabIndex = 2 $CBsourceSite.TabIndex = 3
# #
# CBdestSite # CBdestSite
# #
@ -112,14 +123,14 @@ $CBdestSite.FormattingEnabled = $true
$CBdestSite.Location = New-Object System.Drawing.Point(23, 113) $CBdestSite.Location = New-Object System.Drawing.Point(23, 113)
$CBdestSite.Name = "CBdestSite" $CBdestSite.Name = "CBdestSite"
$CBdestSite.Size = New-Object System.Drawing.Size(587, 21) $CBdestSite.Size = New-Object System.Drawing.Size(587, 21)
$CBdestSite.TabIndex = 3 $CBdestSite.TabIndex = 4
# #
# progressBar1 # progressBar1
# #
$progressBar1.Location = New-Object System.Drawing.Point(8, 369) $progressBar1.Location = New-Object System.Drawing.Point(8, 369)
$progressBar1.Name = "progressBar1" $progressBar1.Name = "progressBar1"
$progressBar1.Size = New-Object System.Drawing.Size(776, 23) $progressBar1.Size = New-Object System.Drawing.Size(776, 23)
$progressBar1.TabIndex = 4 $progressBar1.TabIndex = 5
# #
# label1 # label1
# #
@ -128,7 +139,7 @@ $label1.ForeColor = [System.Drawing.Color]::Black
$label1.Location = New-Object System.Drawing.Point(23, 19) $label1.Location = New-Object System.Drawing.Point(23, 19)
$label1.Name = "label1" $label1.Name = "label1"
$label1.Size = New-Object System.Drawing.Size(41, 13) $label1.Size = New-Object System.Drawing.Size(41, 13)
$label1.TabIndex = 5 $label1.TabIndex = 6
$label1.Text = "Source" $label1.Text = "Source"
# #
# label2 # label2
@ -138,7 +149,7 @@ $label2.ForeColor = [System.Drawing.Color]::Black
$label2.Location = New-Object System.Drawing.Point(23, 88) $label2.Location = New-Object System.Drawing.Point(23, 88)
$label2.Name = "label2" $label2.Name = "label2"
$label2.Size = New-Object System.Drawing.Size(60, 13) $label2.Size = New-Object System.Drawing.Size(60, 13)
$label2.TabIndex = 6 $label2.TabIndex = 7
$label2.Text = "Destination" $label2.Text = "Destination"
# #
# tabs # tabs
@ -152,7 +163,7 @@ $tabs.Location = New-Object System.Drawing.Point(0, 27)
$tabs.Name = "tabs" $tabs.Name = "tabs"
$tabs.SelectedIndex = 0 $tabs.SelectedIndex = 0
$tabs.Size = New-Object System.Drawing.Size(800, 424) $tabs.Size = New-Object System.Drawing.Size(800, 424)
$tabs.TabIndex = 7 $tabs.TabIndex = 8
# #
# tabPage1 # tabPage1
# #
@ -161,6 +172,7 @@ $tabPage1.Controls.Add($label1)
$tabPage1.Controls.Add($progressBar1) $tabPage1.Controls.Add($progressBar1)
$tabPage1.Controls.Add($label2) $tabPage1.Controls.Add($label2)
$tabPage1.Controls.Add($Bgo) $tabPage1.Controls.Add($Bgo)
$tabPage1.Controls.Add($BlistSites)
$tabPage1.Controls.Add($CBsourceSite) $tabPage1.Controls.Add($CBsourceSite)
$tabPage1.Controls.Add($CBdestSite) $tabPage1.Controls.Add($CBdestSite)
$tabPage1.Location = New-Object System.Drawing.Point(4, 22) $tabPage1.Location = New-Object System.Drawing.Point(4, 22)
@ -281,7 +293,7 @@ $button1.Location = New-Object System.Drawing.Point(21, 29)
$button1.Name = "button1" $button1.Name = "button1"
$button1.Size = New-Object System.Drawing.Size(174, 23) $button1.Size = New-Object System.Drawing.Size(174, 23)
$button1.TabIndex = 3 $button1.TabIndex = 3
$button1.Text = "Choix de l\'emplacement..." $button1.Text = "Choix de l'emplacement..."
$button1.UseVisualStyleBackColor = $true $button1.UseVisualStyleBackColor = $true
# #
# checkBox1 # checkBox1
@ -356,31 +368,53 @@ $FMain.MainMenuStrip = $menuStrip1
$FMain.Name = "FMain" $FMain.Name = "FMain"
$FMain.Text = "SharePoint Utils GUI" $FMain.Text = "SharePoint Utils GUI"
#Onglet Move
##Lister les sites dans les comboBoxes
$BlistSites.Add_Click({
#On vide la variable lastError pour ne pas avoir de faux positifs
$lastError=''
#On stocke la derniere erreur
$lastError=$ERROR[0]
#A ameliorer, mais pour l'instant, ca devrait passer
if([string]::IsNullOrEmpty($lastError)){
$sitesList=@()
$sitesList = Get-SPOSite | Select url
$CBsourceSite.Items.AddRange($sitesList)
$CBdestSite.Items.AddRange($sitesList)
}
elseif(-not ([string]::IsNullOrEmpty($lastError))){
$sitesListError=@('Circulez','Ya rien a voir')
$CBsourceSite.Items.AddRange($sitesListError)
$CBdestSite.Items.AddRange($sitesListError)}
else{
$LresultsMove.Items.Add("Connectez-vous au tenant d'abord")
}
})
#Onglet Parametres
##Connexion Sharepoint
$BconnectSP.Add_Click({ $BconnectSP.Add_Click({
$tenantURL = $URLTenant.Text $tenantURL = $URLTenant.Text
$ConnResult = Connect-PnPOnline -Url $tenantURL -Interactive | Out-String Connect-PnPOnline -Url $tenantURL -Interactive 2>&1 | Out-String
Write-Host $ConnResult
$ConnBool = $ConnResult -contains "Host not reachable" Switch ($ERROR)
if($ConnBool = $true)
{ {
{$ERROR[0] -match "Host not reachable" }{
$label4.Text = "Injoignable" $label4.Text = "Injoignable"
$label4.ForeColor = [System.Drawing.Color]::MediumVioletRed
} }
else{ {$ERROR[0] -match "User canceled authentication."}{
$ConnBool = $ConnResult -contains "User canceled authentication." $label4.Text = "Annulé"
if($ConnBool = $true) $label4.ForeColor = [System.Drawing.Color]::MediumVioletRed
{
$label4.Text = "Déconnecté"
} }
else{ Default {
$label4.ForeColor = [System.Drawing.Color]::Green
$label4.Text = "Connecté" $label4.Text = "Connecté"
$label4.ForeColor = [System.Drawing.Color]::Green
}
} }
}
}) })