Compare commits
32 Commits
54ee71c7f2
...
1.0.0
Author | SHA1 | Date | |
---|---|---|---|
07bf2c14ce | |||
f308f5e804 | |||
826c49d164 | |||
7df974133a | |||
e7d688f972 | |||
842a474a80 | |||
7285578906 | |||
67f3e3a4fa | |||
5de0e4613d | |||
1ea4f9e09c | |||
74d891415f | |||
15a7637596 | |||
ec5cb7dc4a | |||
9409e59f57 | |||
|
8ee990cca2 | ||
|
d6982c4927 | ||
|
bc97219e5e | ||
|
eadda6107c | ||
|
2dd5bd9217 | ||
|
09d5e0f281 | ||
|
9c7533edb0 | ||
66bd96e180 | |||
5614dcb11c | |||
|
7824d55859 | ||
|
5f11213de5 | ||
|
a42c3bf5ef | ||
|
a66fb59b6e | ||
|
f3634db543 | ||
f401ceb825 | |||
|
f120caa0e2 | ||
993825bea5 | |||
8b50ddb79c |
115
AD/CreateN1-N2Users/Create-ADtechs.ps1
Normal file
115
AD/CreateN1-N2Users/Create-ADtechs.ps1
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
#On vérifie que les modules soient bien installés
|
||||||
|
if (Get-Module -ListAvailable -Name PSWriteColor) {
|
||||||
|
$modExiste = $true
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$modExiste = $false
|
||||||
|
}
|
||||||
|
|
||||||
|
#Cette étape permet de désactiver les messages de confirmation d'install
|
||||||
|
Set-PSRepository -Name 'PSGallery' -InstallationPolicy Trusted
|
||||||
|
|
||||||
|
switch ($modExiste) {
|
||||||
|
$true{Import-Module ActiveDirectory;Import-Module PSWriteColor}
|
||||||
|
$false{Install-Module PSWriteColor -Confirm:$False;Import-Module ActiveDirectory;Import-Module PSWriteColor}
|
||||||
|
Default {Import-Module ActiveDirectory;Import-Module PSWriteColor}
|
||||||
|
}
|
||||||
|
|
||||||
|
#On crée le CSV pour y stocker les ID
|
||||||
|
$pcName = (Get-ComputerInfo).CSName
|
||||||
|
Set-Content "C:\techLogins-$pcName.csv" -Value "Username,Password"
|
||||||
|
|
||||||
|
########### Fonctions ###########
|
||||||
|
function GenPass { #Genere un mdp aléatoire selon les parametres indiqués
|
||||||
|
|
||||||
|
$TokenSet = @{
|
||||||
|
U = [Char[]]'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
||||||
|
L = [Char[]]'abcdefghijklmnopqrstuvwxyz'
|
||||||
|
N = [Char[]]'0123456789'
|
||||||
|
S = [Char[]]'!"#$%&()*+,-.:;<=>?@[]^_`{}~'
|
||||||
|
}
|
||||||
|
|
||||||
|
$Upper = Get-Random -Count 5 -InputObject $TokenSet.U
|
||||||
|
$Lower = Get-Random -Count 5 -InputObject $TokenSet.L
|
||||||
|
$Number = Get-Random -Count 5 -InputObject $TokenSet.N
|
||||||
|
$Special = Get-Random -Count 5 -InputObject $TokenSet.S
|
||||||
|
|
||||||
|
$StringSet = $Upper + $Lower + $Number + $Special
|
||||||
|
|
||||||
|
$RdString = (Get-Random -Count 15 -InputObject $StringSet) -join ''
|
||||||
|
|
||||||
|
return $RdString
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function GetADSID { #On récupere le SID de l'AD pour pouvoir l'intégrer aux groupes qui en ont besoin
|
||||||
|
$fullSID = (Get-ADDomain).DomainSID.Value
|
||||||
|
$domaineSID = $fullSID.split("-",5)[-1]
|
||||||
|
return $domaineSID
|
||||||
|
}
|
||||||
|
|
||||||
|
########### Variables ###########
|
||||||
|
$userList = "Tech-N1","Tech-N2","Tech-N3"
|
||||||
|
|
||||||
|
# On récupère le SID du serveur car certains SID de groupes en ont besoin
|
||||||
|
$domaineSID = (GetADSID)
|
||||||
|
|
||||||
|
# On utilise le SID des groupes au lieu de leur noms familliers car Microsoft les traduit dans la langue cible du serveur
|
||||||
|
$grpAccountOp = "S-1-5-32-548"
|
||||||
|
$grpDomainAdm = "S-1-5-21-$domaineSID-512"
|
||||||
|
$grpPrintOp = "S-1-5-32-550"
|
||||||
|
#$grpServerOp = "S-1-5-32-549" Pas utilisé
|
||||||
|
#$grpPowerUsers = "S-1-5-32-547" Déprécié
|
||||||
|
$grpDHCPadm = "S-1-5-21-$domaineSID-1111"
|
||||||
|
$grpDHCPuser = "S-1-5-21-$domaineSID-1110"
|
||||||
|
$grpGPOadmin = "S-1-5-21-$domaineSID-520"
|
||||||
|
$grpNetAdmin = "S-1-5-32-556"
|
||||||
|
#################################
|
||||||
|
|
||||||
|
|
||||||
|
########### Script ############
|
||||||
|
|
||||||
|
#Pour chaque user, on le crée + ajoute aux bons groupes
|
||||||
|
ForEach($user in $userList){
|
||||||
|
try{
|
||||||
|
# On vérifie si l'utilisateur existe déjà, passe au suivant si oui
|
||||||
|
$existingUser = Get-ADUser -Filter { Name -eq $user } -ErrorAction SilentlyContinue
|
||||||
|
if ($existingUser) {
|
||||||
|
Write-Color -Text "L'utilisateur ", $user, " existe déjà. Application des permissions." -Color White, Yellow
|
||||||
|
}
|
||||||
|
$userPass = (GenPass)
|
||||||
|
$userEncPass = ConvertTo-SecureString -String $userPass -AsPlainText -Force
|
||||||
|
$detailsUser = @{
|
||||||
|
Name = $user
|
||||||
|
AccountPassword = $userEncPass
|
||||||
|
Enabled = $true
|
||||||
|
ChangePasswordAtLogon = $false
|
||||||
|
PasswordNeverExpires = $true #On fait en sorte qu'il n'expire pas
|
||||||
|
}
|
||||||
|
New-ADUser @detailsUser #On cree l'user...
|
||||||
|
|
||||||
|
#...puis on l'ajoute aux bons groupes
|
||||||
|
switch ($user) {
|
||||||
|
"Tech-N1"{$Groups = @($grpAccountOp,$grpPrintOp,$grpDHCPuser)}
|
||||||
|
"Tech-N2"{$Groups = @($grpAccountOp,$grpPrintOp,$grpDHCPadm,$grpGPOadmin,$grpNetAdmin)}
|
||||||
|
"Tech-N3"{$Groups = @($grpDomainAdm)}
|
||||||
|
Default {}
|
||||||
|
}
|
||||||
|
|
||||||
|
$newCsvLine = @([PSCustomObject]@{Username = $user; Password = $userPass})
|
||||||
|
$newCsvLine | Export-CSV "C:\techLogins-$pcName.csv" -Append -NoTypeInformation -Encoding UTF8
|
||||||
|
|
||||||
|
ForEach ($Group in $Groups) {
|
||||||
|
|
||||||
|
Add-ADPrincipalGroupMembership $User -MemberOf $Group
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Color -Text "L'utilisateur ",$User," a bien été crée. Son mot de passe est ",$userPass -Color White,Green,White,Cyan
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
Write-Error "Erreur pour l'utilisateur $user : $_"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Color -Text "Les utilisateurs ainsi que leur mots de passes ont été exportés ici : ","C:\techLogins-$pcName.csv" -Color White,Green
|
17
Intune/Random-PWGen.ps1
Normal file
17
Intune/Random-PWGen.ps1
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
$TokenSet = @{
|
||||||
|
U = [Char[]]'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
||||||
|
L = [Char[]]'abcdefghijklmnopqrstuvwxyz'
|
||||||
|
N = [Char[]]'0123456789'
|
||||||
|
S = [Char[]]'!"#$%&''()*+,-./:;<=>?@[\]^_`{|}~'
|
||||||
|
}
|
||||||
|
|
||||||
|
$Upper = Get-Random -Count 5 -InputObject $TokenSet.U
|
||||||
|
$Lower = Get-Random -Count 5 -InputObject $TokenSet.L
|
||||||
|
$Number = Get-Random -Count 5 -InputObject $TokenSet.N
|
||||||
|
$Special = Get-Random -Count 5 -InputObject $TokenSet.S
|
||||||
|
|
||||||
|
$StringSet = $Upper + $Lower + $Number + $Special
|
||||||
|
|
||||||
|
$RdString = (Get-Random -Count 15 -InputObject $StringSet) -join ''
|
||||||
|
|
||||||
|
#You can use now $RdString in your script to make a random password to an AD user or other stuff...
|
7
Misc/Multi-Thread/template.ps1
Normal file
7
Misc/Multi-Thread/template.ps1
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
# This is a template for multi-threaded stuff, or at least it should be...
|
||||||
|
|
||||||
|
# We start a new job and store it in a variable to be able to display said job later by invoking the variable in the Receive-Job cmdlet.
|
||||||
|
$Job = Start-Job -ScriptBlock {Write-Output 'Hello World'}
|
||||||
|
Receive-Job $Job # Will display Hello World in the cmd
|
||||||
|
|
||||||
|
|
11
Sharepoint/gui/spmover/.vscode/launch.json
vendored
Normal file
11
Sharepoint/gui/spmover/.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "PowerShell: Launch Script",
|
||||||
|
"type": "PowerShell",
|
||||||
|
"request": "launch",
|
||||||
|
"script": "${workspaceFolder}\\sputils.ps1",
|
||||||
|
"args": []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
3
Sharepoint/gui/spmover/readme.md
Normal file
3
Sharepoint/gui/spmover/readme.md
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# SharePoint Utils
|
||||||
|
|
||||||
|
Sharepoint Utils concatenate all the useful scripts useed to manage your SharePoints in one easy to use GUI.
|
@@ -12,13 +12,25 @@
|
|||||||
# Source : C:\Users\SebastienQUEROL\source\repos\sharepointmover-gui\Form1.Designer.cs
|
# Source : C:\Users\SebastienQUEROL\source\repos\sharepointmover-gui\Form1.Designer.cs
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
function Get-ScriptDirectory
|
###############Thread Setup
|
||||||
{ #Return the directory name of this script
|
|
||||||
$Invocation = (Get-Variable MyInvocation -Scope 1).Value
|
|
||||||
Split-Path $Invocation.MyCommand.Path
|
|
||||||
}
|
|
||||||
|
|
||||||
$ScriptPath = Get-ScriptDirectory
|
$Global:syncHash = [hashtable]::Synchronized(@{})
|
||||||
|
$newRunspace =[runspacefactory]::CreateRunspace()
|
||||||
|
$newRunspace.ApartmentState ="STA"
|
||||||
|
$newRunspace.ThreadOptions ="ReuseThread"
|
||||||
|
$newRunspace.Open()
|
||||||
|
$newRunspace.SessionStateProxy.SetVariable("syncHash",$syncHash)
|
||||||
|
|
||||||
|
###########################
|
||||||
|
|
||||||
|
##Aucune foutre idée de ce qu'est cense faire ce morceau de code, ca a été généré par le createur de forms
|
||||||
|
# function Get-ScriptDirectory
|
||||||
|
# { #Return the directory name of this script
|
||||||
|
# $Invocation = (Get-Variable MyInvocation -Scope 1).Value
|
||||||
|
# Split-Path $Invocation.MyCommand.Path
|
||||||
|
# }
|
||||||
|
# $ScriptPath = Get-ScriptDirectory
|
||||||
|
###
|
||||||
|
|
||||||
# Chargement des assemblies externes
|
# Chargement des assemblies externes
|
||||||
Add-Type -AssemblyName System.Windows.Forms
|
Add-Type -AssemblyName System.Windows.Forms
|
||||||
@@ -32,6 +44,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
|
||||||
@@ -42,7 +55,7 @@ $tabs = New-Object System.Windows.Forms.TabControl
|
|||||||
$tabPage1 = New-Object System.Windows.Forms.TabPage
|
$tabPage1 = New-Object System.Windows.Forms.TabPage
|
||||||
$tabPage2 = New-Object System.Windows.Forms.TabPage
|
$tabPage2 = New-Object System.Windows.Forms.TabPage
|
||||||
$BconnectSP = New-Object System.Windows.Forms.Button
|
$BconnectSP = New-Object System.Windows.Forms.Button
|
||||||
$textBox1 = New-Object System.Windows.Forms.TextBox
|
$URLTenant = New-Object System.Windows.Forms.TextBox
|
||||||
$label3 = New-Object System.Windows.Forms.Label
|
$label3 = New-Object System.Windows.Forms.Label
|
||||||
$groupBox1 = New-Object System.Windows.Forms.GroupBox
|
$groupBox1 = New-Object System.Windows.Forms.GroupBox
|
||||||
$groupBox2 = New-Object System.Windows.Forms.GroupBox
|
$groupBox2 = New-Object System.Windows.Forms.GroupBox
|
||||||
@@ -98,28 +111,38 @@ $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
|
||||||
#
|
#
|
||||||
$comboBox1.FormattingEnabled = $true
|
$CBsourceSite.FormattingEnabled = $true
|
||||||
$comboBox1.Location = New-Object System.Drawing.Point(23, 44)
|
$CBsourceSite.Location = New-Object System.Drawing.Point(23, 44)
|
||||||
$comboBox1.Name = "comboBox1"
|
$CBsourceSite.Name = "CBsourceSite"
|
||||||
$comboBox1.Size = New-Object System.Drawing.Size(587, 21)
|
$CBsourceSite.Size = New-Object System.Drawing.Size(587, 21)
|
||||||
$comboBox1.TabIndex = 2
|
$CBsourceSite.TabIndex = 3
|
||||||
#
|
#
|
||||||
# CBdestSite
|
# CBdestSite
|
||||||
#
|
#
|
||||||
$comboBox2.FormattingEnabled = $true
|
$CBdestSite.FormattingEnabled = $true
|
||||||
$comboBox2.Location = New-Object System.Drawing.Point(23, 113)
|
$CBdestSite.Location = New-Object System.Drawing.Point(23, 113)
|
||||||
$comboBox2.Name = "comboBox2"
|
$CBdestSite.Name = "CBdestSite"
|
||||||
$comboBox2.Size = New-Object System.Drawing.Size(587, 21)
|
$CBdestSite.Size = New-Object System.Drawing.Size(587, 21)
|
||||||
$comboBox2.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 +151,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 +161,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 +175,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,8 +184,9 @@ $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($comboBox1)
|
$tabPage1.Controls.Add($BlistSites)
|
||||||
$tabPage1.Controls.Add($comboBox2)
|
$tabPage1.Controls.Add($CBsourceSite)
|
||||||
|
$tabPage1.Controls.Add($CBdestSite)
|
||||||
$tabPage1.Location = New-Object System.Drawing.Point(4, 22)
|
$tabPage1.Location = New-Object System.Drawing.Point(4, 22)
|
||||||
$tabPage1.Name = "tabPage1"
|
$tabPage1.Name = "tabPage1"
|
||||||
$tabPage1.Padding = New-Object System.Windows.Forms.Padding(3)
|
$tabPage1.Padding = New-Object System.Windows.Forms.Padding(3)
|
||||||
@@ -193,12 +217,13 @@ $BconnectSP.TabIndex = 0
|
|||||||
$BconnectSP.Text = "Connexion"
|
$BconnectSP.Text = "Connexion"
|
||||||
$BconnectSP.UseVisualStyleBackColor = $true
|
$BconnectSP.UseVisualStyleBackColor = $true
|
||||||
#
|
#
|
||||||
# textBox1
|
# URLTenant
|
||||||
#
|
#
|
||||||
$textBox1.Location = New-Object System.Drawing.Point(22, 55)
|
$URLTenant.Location = New-Object System.Drawing.Point(22, 55)
|
||||||
$textBox1.Name = "textBox1"
|
$URLTenant.Name = "URLTenant"
|
||||||
$textBox1.Size = New-Object System.Drawing.Size(325, 20)
|
$URLTenant.Text = "https://guycarlier.sharepoint.com"
|
||||||
$textBox1.TabIndex = 1
|
$URLTenant.Size = New-Object System.Drawing.Size(325, 20)
|
||||||
|
$URLTenant.TabIndex = 1
|
||||||
#
|
#
|
||||||
# label3
|
# label3
|
||||||
#
|
#
|
||||||
@@ -215,7 +240,7 @@ $label3.Text = "URL du tenant SharePoint"
|
|||||||
$groupBox1.Controls.Add($label4)
|
$groupBox1.Controls.Add($label4)
|
||||||
$groupBox1.Controls.Add($label3)
|
$groupBox1.Controls.Add($label3)
|
||||||
$groupBox1.Controls.Add($BconnectSP)
|
$groupBox1.Controls.Add($BconnectSP)
|
||||||
$groupBox1.Controls.Add($textBox1)
|
$groupBox1.Controls.Add($URLTenant)
|
||||||
$groupBox1.Location = New-Object System.Drawing.Point(8, 6)
|
$groupBox1.Location = New-Object System.Drawing.Point(8, 6)
|
||||||
$groupBox1.Name = "groupBox1"
|
$groupBox1.Name = "groupBox1"
|
||||||
$groupBox1.Size = New-Object System.Drawing.Size(473, 100)
|
$groupBox1.Size = New-Object System.Drawing.Size(473, 100)
|
||||||
@@ -280,7 +305,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
|
||||||
@@ -302,8 +327,19 @@ $label4.Location = New-Object System.Drawing.Point(380, 32)
|
|||||||
$label4.Name = "label4"
|
$label4.Name = "label4"
|
||||||
$label4.Size = New-Object System.Drawing.Size(66, 13)
|
$label4.Size = New-Object System.Drawing.Size(66, 13)
|
||||||
$label4.TabIndex = 3
|
$label4.TabIndex = 3
|
||||||
$label4.Text = "Déconnecté"
|
|
||||||
$label4.TextAlign = [System.Drawing.ContentAlignment]::MiddleCenter
|
$label4.TextAlign = [System.Drawing.ContentAlignment]::MiddleCenter
|
||||||
|
##On modifie le texte du label en fonction de l'état initial de la connection a PNPOnline
|
||||||
|
$pnpConnection = Get-PnPConnection | Out-string
|
||||||
|
if(-not ([string]::IsNullOrEmpty($pnpConnection))){
|
||||||
|
$pnpConnection -match "Url : (?<content>.*)/"
|
||||||
|
$pnpConnectionUrl = $matches["content"]
|
||||||
|
$label4.Text = "Connecté"
|
||||||
|
$label4.ForeColor = [System.Drawing.Color]::Green
|
||||||
|
$URLTenant.Text = $pnpConnectionUrl
|
||||||
|
}else{
|
||||||
|
$label4.Text = "Déconnecté"
|
||||||
|
$label4.ForeColor = [System.Drawing.Color]::MediumVioletRed
|
||||||
|
}
|
||||||
#
|
#
|
||||||
# tabPage3
|
# tabPage3
|
||||||
#
|
#
|
||||||
@@ -340,9 +376,12 @@ $tabPage5.UseVisualStyleBackColor = $true
|
|||||||
$LresultsMove.HideSelection = $false
|
$LresultsMove.HideSelection = $false
|
||||||
$LresultsMove.Location = New-Object System.Drawing.Point(8, 173)
|
$LresultsMove.Location = New-Object System.Drawing.Point(8, 173)
|
||||||
$LresultsMove.Name = "LresultsMove"
|
$LresultsMove.Name = "LresultsMove"
|
||||||
|
#$LresultsMove.FullRowSelect = true
|
||||||
$LresultsMove.Size = New-Object System.Drawing.Size(776, 190)
|
$LresultsMove.Size = New-Object System.Drawing.Size(776, 190)
|
||||||
$LresultsMove.TabIndex = 7
|
$LresultsMove.TabIndex = 7
|
||||||
$LresultsMove.UseCompatibleStateImageBehavior = $false
|
$LresultsMove.AutoSize = $true
|
||||||
|
#$LresultsMove.MultiColumn = $false
|
||||||
|
#$LresultsMove.UseCompatibleStateImageBehavior = $false
|
||||||
#
|
#
|
||||||
# FMain
|
# FMain
|
||||||
#
|
#
|
||||||
@@ -353,7 +392,131 @@ $FMain.Controls.Add($menuStrip1)
|
|||||||
$FMain.ForeColor = [System.Drawing.Color]::Black
|
$FMain.ForeColor = [System.Drawing.Color]::Black
|
||||||
$FMain.MainMenuStrip = $menuStrip1
|
$FMain.MainMenuStrip = $menuStrip1
|
||||||
$FMain.Name = "FMain"
|
$FMain.Name = "FMain"
|
||||||
$FMain.Text = "SharePoint Manager GUI"
|
$FMain.Text = "SharePoint Utils GUI"
|
||||||
|
|
||||||
|
#Onglet Move
|
||||||
|
##Lister les sites dans les comboBoxes
|
||||||
|
#### On lance le ScriptBlock dans un runspace au clic du bouton BlistSites
|
||||||
|
$BlistSites.Add_Click({
|
||||||
|
$newRunspace =[runspacefactory]::CreateRunspace()
|
||||||
|
$newRunspace.ApartmentState ="STA"
|
||||||
|
$newRunspace.ThreadOptions ="ReuseThread"
|
||||||
|
$newRunspace.Open()
|
||||||
|
$newRunspace.SessionStateProxy.SetVariable("syncHash",$syncHash)
|
||||||
|
|
||||||
|
$BlistSitesRunSpace = [PowerShell]::Create().AddScript({
|
||||||
|
|
||||||
|
#On vide la variable pnpConnection pour ne pas avoir de faux positifs
|
||||||
|
$pnpConnection=$Null
|
||||||
|
#On stocke la derniere connection PnP
|
||||||
|
$pnpConnection = Get-PnPConnection | Out-string
|
||||||
|
#A ameliorer, mais pour l'instant, ca devrait passer
|
||||||
|
if(-not ([string]::IsNullOrEmpty($pnpConnection))){
|
||||||
|
$CBdestSite.Items.Clear()
|
||||||
|
$CBsourceSite.Items.Clear()
|
||||||
|
$sitesList = $null
|
||||||
|
$sitesList = Get-PnPTenantSite | Where-Object -Property Template -NotIn ("SRCHCEN#0", "REDIRECTSITE#0", "SPSMSITEHOST#0", "APPCATALOG#0", "POINTPUBLISHINGHUB#0", "EDISC#0", "STS#-1", 'EHS#1','POINTPUBLISHINGTOPIC#0') | Select-Object url
|
||||||
|
$LresultsMove.Items.Clear()
|
||||||
|
foreach($siteUrl in $sitesList){
|
||||||
|
$siteUrl -match "@{Url=(?<content>.*)}"
|
||||||
|
$siteUrlClean = $matches["content"]
|
||||||
|
$CBsourceSite.Items.Add([string]$siteUrlClean)
|
||||||
|
$CBdestSite.Items.Add([string]$siteUrlClean)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elseif(([string]::IsNullOrEmpty($pnpConnection))){
|
||||||
|
$LresultsMove.Items.Clear()
|
||||||
|
$LresultsMove.Items.Add("Connectez-vous au tenant d'abord")
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$LresultsMove.Items.Clear()
|
||||||
|
$LresultsMove.Items.Add("Connectez-vous au tenant d'abord")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
$BlistSitesRunSpace.PowerShell.Runspace = $newRunspace
|
||||||
|
$BlistSitesRunSpace.Thread = $BlistSitesRunSpace.PowerShell.BeginInvoke()
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
##Bouger les dossiers
|
||||||
|
# $copyIt = {
|
||||||
|
# param ($sourceSite,$destSite)
|
||||||
|
|
||||||
|
# $sourceSite = $sourceSite -Replace '[A-Za-z]+://([A-Za-z]+(\.[A-Za-z]+)+)',''
|
||||||
|
# $destSite = $destSite -Replace '[A-Za-z]+://([A-Za-z]+(\.[A-Za-z]+)+)',''
|
||||||
|
|
||||||
|
# $jobCopyPending = Copy-PnPFile -SourceUrl "$sourceSite" -TargetUrl "$destSite" -Force -OverwriteIfAlreadyExists
|
||||||
|
# $jobStatus = Receive-PnPCopyMoveJobStatus -Job $jobCopyPending -Wait
|
||||||
|
# Write-Output $jobStatus
|
||||||
|
|
||||||
|
# }
|
||||||
|
|
||||||
|
$Bgo.Add_Click({
|
||||||
|
|
||||||
|
$newRunspace =[runspacefactory]::CreateRunspace()
|
||||||
|
$newRunspace.ApartmentState ="STA"
|
||||||
|
$newRunspace.ThreadOptions ="ReuseThread"
|
||||||
|
$newRunspace.Open()
|
||||||
|
$newRunspace.SessionStateProxy.SetVariable("syncHash",$syncHash)
|
||||||
|
|
||||||
|
$copySPRunspace.PowerShell = [PowerShell]::Create().AddScript({
|
||||||
|
$destSite = $CBdestSite.Text
|
||||||
|
$sourceSite = $CBsourceSite.Text
|
||||||
|
$sourceSite = $sourceSite -Replace '[A-Za-z]+://([A-Za-z]+(\.[A-Za-z]+)+)',''
|
||||||
|
$destSite = $destSite -Replace '[A-Za-z]+://([A-Za-z]+(\.[A-Za-z]+)+)',''
|
||||||
|
|
||||||
|
$jobCopyPending = Copy-PnPFile -SourceUrl "$sourceSite" -TargetUrl "$destSite" -Force -OverwriteIfAlreadyExists
|
||||||
|
$jobStatus = Receive-PnPCopyMoveJobStatus -Job $jobCopyPending -Wait
|
||||||
|
Write-Output $jobStatus
|
||||||
|
})
|
||||||
|
$copySPRunspace.PowerShell.Runspace = $newRunspace
|
||||||
|
$copySPRunspace.Thread = $copySPRunspace.PowerShell.BeginInvoke()
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
#Onglet Parametres
|
||||||
|
##Connexion Sharepoint
|
||||||
|
$pnpConnection=$null
|
||||||
|
$pnpConnection = Get-PnPConnection | Out-string
|
||||||
|
$tenantURL = $URLTenant.Text
|
||||||
|
|
||||||
|
$BconnectSP.Add_Click({
|
||||||
|
|
||||||
|
Disconnect-PnPOnline
|
||||||
|
$newRunspace =[runspacefactory]::CreateRunspace()
|
||||||
|
$newRunspace.ApartmentState ="STA"
|
||||||
|
$newRunspace.ThreadOptions ="ReuseThread"
|
||||||
|
$newRunspace.Open()
|
||||||
|
$newRunspace.SessionStateProxy.SetVariable("syncHash",$syncHash)
|
||||||
|
|
||||||
|
$connectToSPRunspace.PowerShell = [PowerShell]::Create().AddScript({
|
||||||
|
Connect-PnPOnline -Url $tenantURL -Interactive | Out-String
|
||||||
|
|
||||||
|
Switch ($ERROR)
|
||||||
|
{
|
||||||
|
{$ERROR[0] -match "Host not reachable" }{
|
||||||
|
$label4.Text = "Injoignable"
|
||||||
|
$label4.ForeColor = [System.Drawing.Color]::MediumVioletRed
|
||||||
|
Break}
|
||||||
|
{$ERROR[0] -match "User canceled authentication."}{
|
||||||
|
$label4.Text = "Annulé"
|
||||||
|
$label4.ForeColor = [System.Drawing.Color]::MediumVioletRed
|
||||||
|
Break}
|
||||||
|
{-not ([string]::IsNullOrEmpty($pnpConnection))}{
|
||||||
|
$label4.Text = "Connecté"
|
||||||
|
$label4.ForeColor = [System.Drawing.Color]::Green
|
||||||
|
}
|
||||||
|
Default {
|
||||||
|
$label4.Text = "Connecté"
|
||||||
|
$label4.ForeColor = [System.Drawing.Color]::Green
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
$connectToSPRunspace.PowerShell.Runspace = $newRunspace
|
||||||
|
$connectToSPRunspace.Thread = $connectToSPRunspace.PowerShell.BeginInvoke()
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
function OnFormClosing_FMain{
|
function OnFormClosing_FMain{
|
||||||
# $this parameter is equal to the sender (object)
|
# $this parameter is equal to the sender (object)
|
||||||
@@ -366,7 +529,14 @@ function OnFormClosing_FMain{
|
|||||||
($_).Cancel= $False
|
($_).Cancel= $False
|
||||||
}
|
}
|
||||||
|
|
||||||
$FMain.Add_FormClosing( { OnFormClosing_FMain} )
|
$FMain.Add_FormClosing({
|
||||||
|
#Disconnect-PnPOnline
|
||||||
|
Write-Host "Goodbye, come again soon :*"
|
||||||
|
$RunspacePool.Close()
|
||||||
|
$RunspacePool.Dispose()
|
||||||
|
[gc]::Collect()
|
||||||
|
OnFormClosing_FMain
|
||||||
|
})
|
||||||
|
|
||||||
$FMain.Add_Shown({$FMain.Activate()})
|
$FMain.Add_Shown({$FMain.Activate()})
|
||||||
$ModalResult=$FMain.ShowDialog()
|
$ModalResult=$FMain.ShowDialog()
|
Reference in New Issue
Block a user