Compare commits
No commits in common. "main" and "beta" have entirely different histories.
|
@ -1,89 +0,0 @@
|
|||
# Check that AzureAD is installed
|
||||
if (-Not (Get-Module -ListAvailable -Name AzureAD)) {
|
||||
|
||||
$install = Read-Host 'The AzureAD PowerShell module is not installed. Do you want to install it now? (Y/n)'
|
||||
|
||||
if($install -eq '' -Or $install -eq 'Y' -Or $install -eq 'Yes'){
|
||||
If (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))
|
||||
{
|
||||
Write-Warning "Administrator permissions are needed to install the AzureAD PowerShell module.`nPlease re-run this script as an Administrator."
|
||||
Exit
|
||||
}
|
||||
|
||||
write-host "Installing"
|
||||
Install-Module -Name AzureAD
|
||||
}
|
||||
else {
|
||||
exit
|
||||
}
|
||||
}
|
||||
|
||||
# Create a temporary file to hold the unformatted results of our Get-AzureADUser query
|
||||
$TempFile = New-TemporaryFile
|
||||
|
||||
#Go ahead and attempt to get the Azure AD user IDs, but catch the error if there is no existing connection to Azure AD
|
||||
Try
|
||||
{
|
||||
Get-AzureADUser -All:$true | Export-Csv -Path $TempFile -NoTypeInformation -encoding Utf8
|
||||
}
|
||||
Catch [Microsoft.Open.Azure.AD.CommonLibrary.AadNeedAuthenticationException]
|
||||
{
|
||||
#Connect to Azure AD. This will show a prompt.
|
||||
Connect-AzureAD | Out-Null
|
||||
|
||||
#Try again
|
||||
Get-AzureADUser -All:$true | Export-Csv -Path $TempFile -NoTypeInformation -encoding Utf8
|
||||
}
|
||||
|
||||
|
||||
# Get the tennant details
|
||||
$Tenant = Get-AzureADTenantDetail
|
||||
|
||||
# Get the unformatted data from the temporary file
|
||||
$azureADUsers = import-csv $TempFile
|
||||
|
||||
# Create the XML file
|
||||
$xmlsettings = New-Object System.Xml.XmlWriterSettings
|
||||
$xmlsettings.Indent = $true
|
||||
$xmlsettings.IndentChars = " "
|
||||
|
||||
$XmlWriter = [System.XML.XmlWriter]::Create("$((Get-Location).Path)\ForensiTAzureID.xml", $xmlsettings)
|
||||
|
||||
# Write the XML Declaration and set the XSL
|
||||
$xmlWriter.WriteStartDocument()
|
||||
$xmlWriter.WriteProcessingInstruction("xml-stylesheet", "type='text/xsl' href='style.xsl'")
|
||||
|
||||
# Start the Root Element
|
||||
$xmlWriter.WriteStartElement("ForensiTAzureID")
|
||||
|
||||
# Write the Azure AD domain details as attributes
|
||||
$xmlWriter.WriteAttributeString("ObjectId", $($Tenant.ObjectId))
|
||||
$xmlWriter.WriteAttributeString("Name", $($Tenant.VerifiedDomains.Name));
|
||||
$xmlWriter.WriteAttributeString("DisplayName", $($Tenant.DisplayName));
|
||||
|
||||
|
||||
#Parse the data
|
||||
ForEach ($azureADUser in $azureADUsers){
|
||||
|
||||
$xmlWriter.WriteStartElement("User")
|
||||
|
||||
$xmlWriter.WriteElementString("UserPrincipalName",$($azureADUser.UserPrincipalName))
|
||||
$xmlWriter.WriteElementString("ObjectId",$($azureADUser.ObjectId))
|
||||
$xmlWriter.WriteElementString("DisplayName",$($azureADUser.DisplayName))
|
||||
|
||||
$xmlWriter.WriteEndElement()
|
||||
}
|
||||
|
||||
$xmlWriter.WriteEndElement()
|
||||
|
||||
# Close the XML Document
|
||||
$xmlWriter.WriteEndDocument()
|
||||
$xmlWriter.Flush()
|
||||
$xmlWriter.Close()
|
||||
|
||||
|
||||
# Clean up
|
||||
Remove-Item $TempFile
|
||||
|
||||
write-host "Azure user ID file created: $((Get-Location).Path)\ForensiTAzureID.xml"
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
#Connexion au Sharepoint (necessaire pour l'utilisation de l'API graph)
|
||||
Connect-PnPOnline -url https://site.sharepoint.com -interactive
|
||||
|
||||
#On precise les parametres basiques, on peut envoyer de n'importe quelle adresse mail du moment qu'elle fait partie du tenant.
|
||||
$EmailParams = @{
|
||||
From = "mail"
|
||||
To = "mail"
|
||||
Subject = "Script envoi de mails" #Titre du mail
|
||||
BodyContentType = "HTML" #Type de contenu du mail
|
||||
Body = "Test" #Contenu du corps du mail, on peut mettre ce qu'on veut
|
||||
Attachments = "logsTest.log" #On peut attacher n'importe quel fichier
|
||||
}
|
||||
|
||||
Send-PnPMail @EmailParams #On envoie
|
11
README.md
11
README.md
|
@ -14,10 +14,9 @@ I added lots of comments and READMEs for all of them, the creation of a wiki und
|
|||
|
||||
## Categories
|
||||
|
||||
- [Active Directory](https://git.azuze.fr/kawa/ps-scripts/src/branch/main/AD)
|
||||
- [Anti Bloatware](https://git.azuze.fr/kawa/ps-scripts/src/branch/main/Anti-Bloat)
|
||||
- [Intune](https://git.azuze.fr/kawa/ps-scripts/src/branch/main/Intune)
|
||||
- [Windows](https://git.azuze.fr/kawa/ps-scripts/src/branch/main/Windows)
|
||||
- [Sharepoint](https://git.azuze.fr/kawa/ps-scripts/src/branch/main/Sharepoint)
|
||||
- [Misc](https://git.azuze.fr/kawa/ps-scripts/src/branch/main/Misc)
|
||||
- [Active Directory](https://git.kawawete.xyz/kawa/ps-scripts/AD)
|
||||
- [Anti Bloatware](https://git.kawawete.xyz/kawa/ps-scripts/Anti-Bloat)
|
||||
- [Intune](https://git.kawawete.xyz/kawa/ps-scripts/Intune)
|
||||
- [Windows](https://git.kawawete.xyz/kawa/ps-scripts/Windows)
|
||||
- [Sharepoint](https://git.kawawete.xyz/kawa/ps-scripts/Sharepoint)
|
||||
|
||||
|
|
|
@ -1,64 +0,0 @@
|
|||
#Config Parameters
|
||||
$SiteURL = Read-Host -Prompt "Entrez l'adresse du site Sharepoint"
|
||||
$VersionsToKeep = 5
|
||||
|
||||
Try {
|
||||
#Connect to PnP Online
|
||||
Connect-PnPOnline -Url $SiteURL -Interactive
|
||||
|
||||
#Get the Context
|
||||
$Ctx= Get-PnPContext
|
||||
|
||||
#Exclude certain libraries
|
||||
$ExcludedLists = @("Form Templates", "Preservation Hold Library","Site Assets", "Pages", "Site Pages", "Images",
|
||||
"Site Collection Documents", "Site Collection Images","Style Library")
|
||||
|
||||
#Get All document libraries
|
||||
$DocumentLibraries = Get-PnPList | Where-Object {$_.BaseType -eq "DocumentLibrary" -and $_.Title -notin $ExcludedLists -and $_.Hidden -eq $false}
|
||||
|
||||
#Iterate through each document library
|
||||
ForEach($Library in $DocumentLibraries)
|
||||
{
|
||||
Write-host "Processing Document Library:"$Library.Title -f Magenta
|
||||
|
||||
#Get All Items from the List - Exclude 'Folder' List Items
|
||||
$ListItems = Get-PnPListItem -List $Library -PageSize 2000 | Where {$_.FileSystemObjectType -eq "File"}
|
||||
|
||||
#Loop through each file
|
||||
ForEach ($Item in $ListItems)
|
||||
{
|
||||
#Get File Versions
|
||||
$File = $Item.File
|
||||
$Versions = $File.Versions
|
||||
$Ctx.Load($File)
|
||||
$Ctx.Load($Versions)
|
||||
$Ctx.ExecuteQuery()
|
||||
|
||||
Write-host -f Yellow "`tScanning File:"$File.Name
|
||||
$VersionsCount = $Versions.Count
|
||||
$VersionsToDelete = $VersionsCount - $VersionsToKeep
|
||||
If($VersionsToDelete -gt 0)
|
||||
{
|
||||
write-host -f Cyan "`t Total Number of Versions of the File:" $VersionsCount
|
||||
$VersionCounter= 0
|
||||
#Delete versions
|
||||
For($i=0; $i -lt $VersionsToDelete; $i++)
|
||||
{
|
||||
If($Versions[$VersionCounter].IsCurrentVersion)
|
||||
{
|
||||
$VersionCounter++
|
||||
Write-host -f Magenta "`t`t Retaining Current Major Version:"$Versions[$VersionCounter].VersionLabel
|
||||
Continue
|
||||
}
|
||||
Write-host -f Cyan "`t Deleting Version:" $Versions[$VersionCounter].VersionLabel
|
||||
$Versions[$VersionCounter].DeleteObject()
|
||||
}
|
||||
$Ctx.ExecuteQuery()
|
||||
Write-Host -f Green "`t Version History is cleaned for the File:"$File.Name
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Catch {
|
||||
write-host -f Red "Error Cleaning up Version History!" $_.Exception.Message
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
{
|
||||
"configurations": [
|
||||
{
|
||||
"name": "PowerShell: Launch Script",
|
||||
"type": "PowerShell",
|
||||
"request": "launch",
|
||||
"script": "${workspaceFolder}\\sputils.ps1",
|
||||
"args": []
|
||||
}
|
||||
]
|
||||
}
|
Binary file not shown.
Binary file not shown.
|
@ -1,14 +0,0 @@
|
|||
20240307 08:51:28: ForEach-Object: C:\Users\SebastienQUEROL\git.azuze.fr\ps-scripts\Sharepoint\gui\spmover\Functions.ps1:43:31 Line | 43 | $Xml.Attributes | ForEach-Object { | ~~~~~~~~~~~~~~~~ | Exception setting "Image": "Cannot convert the "System.Drawing.Bitmap" value of type "System.String" to type "System.Drawing.Image"."
|
||||
20240307 09:27:01: New-Object: C:\Users\SebastienQUEROL\git.azuze.fr\ps-scripts\Sharepoint\gui\spmover\Functions.ps1:33:71 Line | 33 | … ) {$newControl = New-Object System.Windows.Forms.$($Xml.ToString())} | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | Cannot find type [System.Windows.Forms.Image]: verify that the assembly containing this type is loaded.
|
||||
20240307 09:28:50: New-Object: C:\Users\SebastienQUEROL\git.azuze.fr\ps-scripts\Sharepoint\gui\spmover\Functions.ps1:33:71 Line | 33 | … ) {$newControl = New-Object System.Windows.Forms.$($Xml.ToString())} | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | Cannot find type [System.Windows.Forms.Image]: verify that the assembly containing this type is loaded.
|
||||
20240307 09:34:41: ForEach-Object: C:\Users\SebastienQUEROL\git.azuze.fr\ps-scripts\Sharepoint\gui\spmover\Functions.ps1:43:31 Line | 43 | $Xml.Attributes | ForEach-Object { | ~~~~~~~~~~~~~~~~ | Exception setting "Image": "Cannot convert the "System.Drawing.Bitmap" value of type "System.String" to type "System.Drawing.Image"."
|
||||
20240307 09:34:53: ForEach-Object: C:\Users\SebastienQUEROL\git.azuze.fr\ps-scripts\Sharepoint\gui\spmover\Functions.ps1:43:31 Line | 43 | $Xml.Attributes | ForEach-Object { | ~~~~~~~~~~~~~~~~ | Exception setting "Image": "Cannot convert the "System.Drawing.Bitmap" value of type "System.String" to type "System.Drawing.Image"."
|
||||
20240307 09:38:58: ForEach-Object: C:\Users\SebastienQUEROL\git.azuze.fr\ps-scripts\Sharepoint\gui\spmover\Functions.ps1:43:31 Line | 43 | $Xml.Attributes | ForEach-Object { | ~~~~~~~~~~~~~~~~ | Exception setting "Image": "Cannot convert the "System.Drawing.Bitmap" value of type "System.String" to type "System.Drawing.Image"."
|
||||
20240307 09:40:53: ForEach-Object: C:\Users\SebastienQUEROL\git.azuze.fr\ps-scripts\Sharepoint\gui\spmover\Functions.ps1:43:31 Line | 43 | $Xml.Attributes | ForEach-Object { | ~~~~~~~~~~~~~~~~ | Exception setting "Image": "Cannot convert the "System.Drawing.Bitmap" value of type "System.String" to type "System.Drawing.Image"."
|
||||
20240307 09:41:31: ForEach-Object: C:\Users\SebastienQUEROL\git.azuze.fr\ps-scripts\Sharepoint\gui\spmover\Functions.ps1:43:31 Line | 43 | $Xml.Attributes | ForEach-Object { | ~~~~~~~~~~~~~~~~ | Exception setting "Image": "Cannot convert the "System.Drawing.Image" value of type "System.String" to type "System.Drawing.Image"."
|
||||
20240307 09:44:00: ForEach-Object: C:\Users\SebastienQUEROL\git.azuze.fr\ps-scripts\Sharepoint\gui\spmover\Functions.ps1:43:31 Line | 43 | $Xml.Attributes | ForEach-Object { | ~~~~~~~~~~~~~~~~ | Exception setting "Image": "Cannot convert the "System.Drawing.Bitmap" value of type "System.String" to type "System.Drawing.Image"."
|
||||
20240307 09:44:41: ForEach-Object: C:\Users\SebastienQUEROL\git.azuze.fr\ps-scripts\Sharepoint\gui\spmover\Functions.ps1:43:31 Line | 43 | $Xml.Attributes | ForEach-Object { | ~~~~~~~~~~~~~~~~ | Exception setting "Image": "Cannot convert the "System.Drawing.Bitmap" value of type "System.String" to type "System.Drawing.Image"."
|
||||
20240307 09:45:56: ForEach-Object: C:\Users\SebastienQUEROL\git.azuze.fr\ps-scripts\Sharepoint\gui\spmover\Functions.ps1:43:31 Line | 43 | $Xml.Attributes | ForEach-Object { | ~~~~~~~~~~~~~~~~ | Exception setting "Image": "Cannot convert the "System.Drawing.Bitmap" value of type "System.String" to type "System.Drawing.Image"."
|
||||
20240307 09:47:04: ForEach-Object: C:\Users\SebastienQUEROL\git.azuze.fr\ps-scripts\Sharepoint\gui\spmover\Functions.ps1:43:31 Line | 43 | $Xml.Attributes | ForEach-Object { | ~~~~~~~~~~~~~~~~ | Exception setting "Image": "Cannot convert the "System.Drawing.Bitmap" value of type "System.String" to type "System.Drawing.Image"."
|
||||
20240307 09:48:25: ForEach-Object: C:\Users\SebastienQUEROL\git.azuze.fr\ps-scripts\Sharepoint\gui\spmover\Functions.ps1:43:31 Line | 43 | $Xml.Attributes | ForEach-Object { | ~~~~~~~~~~~~~~~~ | Exception calling "Add" with "2" argument(s): "Item has already been added. Key in dictionary: 'lbl_byWho' Key being added: 'lbl_byWho'"
|
||||
20240307 11:16:28: InvalidOperation: Line | 45 | $Script:refs['btn_Start'].Add_Click($eventSB['btn_Start'].Cli … | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | Cannot index into a null array.
|
Binary file not shown.
Before Width: | Height: | Size: 13 KiB |
|
@ -1,3 +0,0 @@
|
|||
# SharePoint Utils
|
||||
|
||||
Sharepoint Utils concatenate all the useful scripts useed to manage your SharePoints in one easy to use GUI.
|
|
@ -1,518 +0,0 @@
|
|||
################################################################################
|
||||
#
|
||||
# Name : C:\Users\SebastienQUEROL\source\repos\sharepointmover-gui\Form1.ps1
|
||||
# Version : 0.1
|
||||
# Author :
|
||||
# Date : 08/03/2024
|
||||
#
|
||||
# Generated with ConvertForm module version 2.0.0
|
||||
# PowerShell version 7.4.1
|
||||
#
|
||||
# Invocation Line : Convert-Form -Path $Source -Destination $Destination -Encoding utf8 -force
|
||||
# Source : C:\Users\SebastienQUEROL\source\repos\sharepointmover-gui\Form1.Designer.cs
|
||||
################################################################################
|
||||
|
||||
###############Thread Setup
|
||||
|
||||
|
||||
###########################
|
||||
|
||||
##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
|
||||
Add-Type -AssemblyName System.Windows.Forms
|
||||
Add-Type -AssemblyName System.Drawing
|
||||
|
||||
$FMain = New-Object System.Windows.Forms.Form
|
||||
|
||||
$components = New-Object System.ComponentModel.Container
|
||||
$menuStrip1 = New-Object System.Windows.Forms.MenuStrip
|
||||
$Mquestion = New-Object System.Windows.Forms.ToolStripMenuItem
|
||||
$MQuestionApropos = New-Object System.Windows.Forms.ToolStripMenuItem
|
||||
$MQuestionWiki = New-Object System.Windows.Forms.ToolStripMenuItem
|
||||
$Bgo = New-Object System.Windows.Forms.Button
|
||||
$BlistSites = New-Object System.Windows.Forms.Button
|
||||
$CBsourceSite = New-Object System.Windows.Forms.ComboBox
|
||||
$CBdestSite = New-Object System.Windows.Forms.ComboBox
|
||||
$progressBar1 = New-Object System.Windows.Forms.ProgressBar
|
||||
$sourceInfo = New-Object System.Windows.Forms.ToolTip($components)
|
||||
$label1 = New-Object System.Windows.Forms.Label
|
||||
$label2 = New-Object System.Windows.Forms.Label
|
||||
$tabs = New-Object System.Windows.Forms.TabControl
|
||||
$tabPage1 = New-Object System.Windows.Forms.TabPage
|
||||
$tabPage2 = New-Object System.Windows.Forms.TabPage
|
||||
$BconnectSP = New-Object System.Windows.Forms.Button
|
||||
$URLTenant = New-Object System.Windows.Forms.TextBox
|
||||
$label3 = New-Object System.Windows.Forms.Label
|
||||
$groupBox1 = New-Object System.Windows.Forms.GroupBox
|
||||
$groupBox2 = New-Object System.Windows.Forms.GroupBox
|
||||
$radioButton1 = New-Object System.Windows.Forms.RadioButton
|
||||
$radioButton2 = New-Object System.Windows.Forms.RadioButton
|
||||
$radioButton3 = New-Object System.Windows.Forms.RadioButton
|
||||
$button1 = New-Object System.Windows.Forms.Button
|
||||
$checkBox1 = New-Object System.Windows.Forms.CheckBox
|
||||
$label4 = New-Object System.Windows.Forms.Label
|
||||
$tabPage3 = New-Object System.Windows.Forms.TabPage
|
||||
$tabPage4 = New-Object System.Windows.Forms.TabPage
|
||||
$tabPage5 = New-Object System.Windows.Forms.TabPage
|
||||
$LresultsMove = New-Object System.Windows.Forms.ListView
|
||||
#
|
||||
# menuStrip1
|
||||
#
|
||||
$menuStrip1.Items.AddRange(@(
|
||||
$Mquestion))
|
||||
$menuStrip1.Location = New-Object System.Drawing.Point(0, 0)
|
||||
$menuStrip1.Name = "menuStrip1"
|
||||
$menuStrip1.Size = New-Object System.Drawing.Size(800, 24)
|
||||
$menuStrip1.TabIndex = 0
|
||||
$menuStrip1.Text = "menuStrip1"
|
||||
#
|
||||
# Mquestion
|
||||
#
|
||||
$Mquestion.DropDownItems.AddRange(@(
|
||||
$MQuestionApropos,
|
||||
$MQuestionWiki))
|
||||
$Mquestion.Name = "Mquestion"
|
||||
$Mquestion.Size = New-Object System.Drawing.Size(24, 20)
|
||||
$Mquestion.Text = "?"
|
||||
#
|
||||
# MQuestionApropos
|
||||
#
|
||||
$MQuestionApropos.Name = "MQuestionApropos"
|
||||
$MQuestionApropos.Size = New-Object System.Drawing.Size(180, 22)
|
||||
$MQuestionApropos.Text = "A propos..."
|
||||
#
|
||||
# MQuestionWiki
|
||||
#
|
||||
$MQuestionWiki.Name = "MQuestionWiki"
|
||||
$MQuestionWiki.Size = New-Object System.Drawing.Size(180, 22)
|
||||
$MQuestionWiki.Text = "Wiki"
|
||||
#
|
||||
# Bgo
|
||||
#
|
||||
$Bgo.ForeColor = [System.Drawing.Color]::Black
|
||||
$Bgo.Location = New-Object System.Drawing.Point(649, 83)
|
||||
$Bgo.Name = "Bgo"
|
||||
$Bgo.Size = New-Object System.Drawing.Size(75, 23)
|
||||
$Bgo.TabIndex = 1
|
||||
$Bgo.Text = "GO"
|
||||
$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.FormattingEnabled = $true
|
||||
$CBsourceSite.Location = New-Object System.Drawing.Point(23, 44)
|
||||
$CBsourceSite.Name = "CBsourceSite"
|
||||
$CBsourceSite.Size = New-Object System.Drawing.Size(587, 21)
|
||||
$CBsourceSite.TabIndex = 3
|
||||
#
|
||||
# CBdestSite
|
||||
#
|
||||
$CBdestSite.FormattingEnabled = $true
|
||||
$CBdestSite.Location = New-Object System.Drawing.Point(23, 113)
|
||||
$CBdestSite.Name = "CBdestSite"
|
||||
$CBdestSite.Size = New-Object System.Drawing.Size(587, 21)
|
||||
$CBdestSite.TabIndex = 4
|
||||
#
|
||||
# progressBar1
|
||||
#
|
||||
$progressBar1.Location = New-Object System.Drawing.Point(8, 369)
|
||||
$progressBar1.Name = "progressBar1"
|
||||
$progressBar1.Size = New-Object System.Drawing.Size(776, 23)
|
||||
$progressBar1.TabIndex = 5
|
||||
#
|
||||
# label1
|
||||
#
|
||||
$label1.AutoSize = $true
|
||||
$label1.ForeColor = [System.Drawing.Color]::Black
|
||||
$label1.Location = New-Object System.Drawing.Point(23, 19)
|
||||
$label1.Name = "label1"
|
||||
$label1.Size = New-Object System.Drawing.Size(41, 13)
|
||||
$label1.TabIndex = 6
|
||||
$label1.Text = "Source"
|
||||
#
|
||||
# label2
|
||||
#
|
||||
$label2.AutoSize = $true
|
||||
$label2.ForeColor = [System.Drawing.Color]::Black
|
||||
$label2.Location = New-Object System.Drawing.Point(23, 88)
|
||||
$label2.Name = "label2"
|
||||
$label2.Size = New-Object System.Drawing.Size(60, 13)
|
||||
$label2.TabIndex = 7
|
||||
$label2.Text = "Destination"
|
||||
#
|
||||
# tabs
|
||||
#
|
||||
$tabs.Controls.Add($tabPage1)
|
||||
$tabs.Controls.Add($tabPage3)
|
||||
$tabs.Controls.Add($tabPage4)
|
||||
$tabs.Controls.Add($tabPage5)
|
||||
$tabs.Controls.Add($tabPage2)
|
||||
$tabs.Location = New-Object System.Drawing.Point(0, 27)
|
||||
$tabs.Name = "tabs"
|
||||
$tabs.SelectedIndex = 0
|
||||
$tabs.Size = New-Object System.Drawing.Size(800, 424)
|
||||
$tabs.TabIndex = 8
|
||||
#
|
||||
# tabPage1
|
||||
#
|
||||
$tabPage1.Controls.Add($LresultsMove)
|
||||
$tabPage1.Controls.Add($label1)
|
||||
$tabPage1.Controls.Add($progressBar1)
|
||||
$tabPage1.Controls.Add($label2)
|
||||
$tabPage1.Controls.Add($Bgo)
|
||||
$tabPage1.Controls.Add($BlistSites)
|
||||
$tabPage1.Controls.Add($CBsourceSite)
|
||||
$tabPage1.Controls.Add($CBdestSite)
|
||||
$tabPage1.Location = New-Object System.Drawing.Point(4, 22)
|
||||
$tabPage1.Name = "tabPage1"
|
||||
$tabPage1.Padding = New-Object System.Windows.Forms.Padding(3)
|
||||
$tabPage1.Size = New-Object System.Drawing.Size(792, 398)
|
||||
$tabPage1.TabIndex = 0
|
||||
$tabPage1.Text = "Move"
|
||||
$tabPage1.UseVisualStyleBackColor = $true
|
||||
#
|
||||
# tabPage2
|
||||
#
|
||||
$tabPage2.Controls.Add($groupBox2)
|
||||
$tabPage2.Controls.Add($groupBox1)
|
||||
$tabPage2.Location = New-Object System.Drawing.Point(4, 22)
|
||||
$tabPage2.Name = "tabPage2"
|
||||
$tabPage2.Padding = New-Object System.Windows.Forms.Padding(3)
|
||||
$tabPage2.Size = New-Object System.Drawing.Size(792, 398)
|
||||
$tabPage2.TabIndex = 1
|
||||
$tabPage2.Text = "Parametres"
|
||||
$tabPage2.UseVisualStyleBackColor = $true
|
||||
#
|
||||
# BconnectSP
|
||||
#
|
||||
$BconnectSP.ForeColor = [System.Drawing.Color]::Black
|
||||
$BconnectSP.Location = New-Object System.Drawing.Point(376, 53)
|
||||
$BconnectSP.Name = "BconnectSP"
|
||||
$BconnectSP.Size = New-Object System.Drawing.Size(75, 23)
|
||||
$BconnectSP.TabIndex = 0
|
||||
$BconnectSP.Text = "Connexion"
|
||||
$BconnectSP.UseVisualStyleBackColor = $true
|
||||
#
|
||||
# URLTenant
|
||||
#
|
||||
$URLTenant.Location = New-Object System.Drawing.Point(22, 55)
|
||||
$URLTenant.Name = "URLTenant"
|
||||
$URLTenant.Text = "https://guycarlier.sharepoint.com"
|
||||
$URLTenant.Size = New-Object System.Drawing.Size(325, 20)
|
||||
$URLTenant.TabIndex = 1
|
||||
#
|
||||
# label3
|
||||
#
|
||||
$label3.AutoSize = $true
|
||||
$label3.ForeColor = [System.Drawing.Color]::Black
|
||||
$label3.Location = New-Object System.Drawing.Point(22, 32)
|
||||
$label3.Name = "label3"
|
||||
$label3.Size = New-Object System.Drawing.Size(132, 13)
|
||||
$label3.TabIndex = 2
|
||||
$label3.Text = "URL du tenant SharePoint"
|
||||
#
|
||||
# groupBox1
|
||||
#
|
||||
$groupBox1.Controls.Add($label4)
|
||||
$groupBox1.Controls.Add($label3)
|
||||
$groupBox1.Controls.Add($BconnectSP)
|
||||
$groupBox1.Controls.Add($URLTenant)
|
||||
$groupBox1.Location = New-Object System.Drawing.Point(8, 6)
|
||||
$groupBox1.Name = "groupBox1"
|
||||
$groupBox1.Size = New-Object System.Drawing.Size(473, 100)
|
||||
$groupBox1.TabIndex = 3
|
||||
$groupBox1.TabStop = $false
|
||||
$groupBox1.Text = "Connexion"
|
||||
#
|
||||
# groupBox2
|
||||
#
|
||||
$groupBox2.Controls.Add($checkBox1)
|
||||
$groupBox2.Controls.Add($button1)
|
||||
$groupBox2.Controls.Add($radioButton3)
|
||||
$groupBox2.Controls.Add($radioButton2)
|
||||
$groupBox2.Controls.Add($radioButton1)
|
||||
$groupBox2.Location = New-Object System.Drawing.Point(9, 113)
|
||||
$groupBox2.Name = "groupBox2"
|
||||
$groupBox2.Size = New-Object System.Drawing.Size(472, 145)
|
||||
$groupBox2.TabIndex = 4
|
||||
$groupBox2.TabStop = $false
|
||||
$groupBox2.Text = "Rapports"
|
||||
#
|
||||
# radioButton1
|
||||
#
|
||||
$radioButton1.AutoSize = $true
|
||||
$radioButton1.ForeColor = [System.Drawing.Color]::Black
|
||||
$radioButton1.Location = New-Object System.Drawing.Point(23, 66)
|
||||
$radioButton1.Name = "radioButton1"
|
||||
$radioButton1.Size = New-Object System.Drawing.Size(141, 17)
|
||||
$radioButton1.TabIndex = 0
|
||||
$radioButton1.TabStop = $true
|
||||
$radioButton1.Text = "Intégralité des messages"
|
||||
$radioButton1.UseVisualStyleBackColor = $true
|
||||
#
|
||||
# radioButton2
|
||||
#
|
||||
$radioButton2.AutoSize = $true
|
||||
$radioButton2.ForeColor = [System.Drawing.Color]::Black
|
||||
$radioButton2.Location = New-Object System.Drawing.Point(23, 92)
|
||||
$radioButton2.Name = "radioButton2"
|
||||
$radioButton2.Size = New-Object System.Drawing.Size(109, 17)
|
||||
$radioButton2.TabIndex = 1
|
||||
$radioButton2.TabStop = $true
|
||||
$radioButton2.Text = "Erreurs seulement"
|
||||
$radioButton2.UseVisualStyleBackColor = $true
|
||||
#
|
||||
# radioButton3
|
||||
#
|
||||
$radioButton3.AutoSize = $true
|
||||
$radioButton3.ForeColor = [System.Drawing.Color]::Black
|
||||
$radioButton3.Location = New-Object System.Drawing.Point(23, 116)
|
||||
$radioButton3.Name = "radioButton3"
|
||||
$radioButton3.Size = New-Object System.Drawing.Size(113, 17)
|
||||
$radioButton3.TabIndex = 2
|
||||
$radioButton3.TabStop = $true
|
||||
$radioButton3.Text = "Réussis seulement"
|
||||
$radioButton3.UseVisualStyleBackColor = $true
|
||||
#
|
||||
# button1
|
||||
#
|
||||
$button1.ForeColor = [System.Drawing.Color]::Black
|
||||
$button1.Location = New-Object System.Drawing.Point(21, 29)
|
||||
$button1.Name = "button1"
|
||||
$button1.Size = New-Object System.Drawing.Size(174, 23)
|
||||
$button1.TabIndex = 3
|
||||
$button1.Text = "Choix de l'emplacement..."
|
||||
$button1.UseVisualStyleBackColor = $true
|
||||
#
|
||||
# checkBox1
|
||||
#
|
||||
$checkBox1.AutoSize = $true
|
||||
$checkBox1.ForeColor = [System.Drawing.Color]::Black
|
||||
$checkBox1.Location = New-Object System.Drawing.Point(189, 68)
|
||||
$checkBox1.Name = "checkBox1"
|
||||
$checkBox1.Size = New-Object System.Drawing.Size(153, 17)
|
||||
$checkBox1.TabIndex = 4
|
||||
$checkBox1.Text = "Inclure ligne de commande"
|
||||
$checkBox1.UseVisualStyleBackColor = $true
|
||||
#
|
||||
# label4
|
||||
#
|
||||
$label4.AutoSize = $true
|
||||
$label4.ForeColor = [System.Drawing.Color]::MediumVioletRed
|
||||
$label4.Location = New-Object System.Drawing.Point(380, 32)
|
||||
$label4.Name = "label4"
|
||||
$label4.Size = New-Object System.Drawing.Size(66, 13)
|
||||
$label4.TabIndex = 3
|
||||
$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.Location = New-Object System.Drawing.Point(4, 22)
|
||||
$tabPage3.Name = "tabPage3"
|
||||
$tabPage3.Padding = New-Object System.Windows.Forms.Padding(3)
|
||||
$tabPage3.Size = New-Object System.Drawing.Size(792, 398)
|
||||
$tabPage3.TabIndex = 2
|
||||
$tabPage3.Text = "Rapports"
|
||||
$tabPage3.UseVisualStyleBackColor = $true
|
||||
#
|
||||
# tabPage4
|
||||
#
|
||||
$tabPage4.Location = New-Object System.Drawing.Point(4, 22)
|
||||
$tabPage4.Name = "tabPage4"
|
||||
$tabPage4.Padding = New-Object System.Windows.Forms.Padding(3)
|
||||
$tabPage4.Size = New-Object System.Drawing.Size(792, 398)
|
||||
$tabPage4.TabIndex = 3
|
||||
$tabPage4.Text = "Import"
|
||||
$tabPage4.UseVisualStyleBackColor = $true
|
||||
#
|
||||
# tabPage5
|
||||
#
|
||||
$tabPage5.Location = New-Object System.Drawing.Point(4, 22)
|
||||
$tabPage5.Name = "tabPage5"
|
||||
$tabPage5.Padding = New-Object System.Windows.Forms.Padding(3)
|
||||
$tabPage5.Size = New-Object System.Drawing.Size(792, 398)
|
||||
$tabPage5.TabIndex = 4
|
||||
$tabPage5.Text = "Audit"
|
||||
$tabPage5.UseVisualStyleBackColor = $true
|
||||
#
|
||||
# LresultsMove
|
||||
#
|
||||
$LresultsMove.HideSelection = $false
|
||||
$LresultsMove.Location = New-Object System.Drawing.Point(8, 173)
|
||||
$LresultsMove.Name = "LresultsMove"
|
||||
#$LresultsMove.FullRowSelect = true
|
||||
$LresultsMove.Size = New-Object System.Drawing.Size(776, 190)
|
||||
$LresultsMove.TabIndex = 7
|
||||
$LresultsMove.AutoSize = $true
|
||||
#$LresultsMove.MultiColumn = $false
|
||||
#$LresultsMove.UseCompatibleStateImageBehavior = $false
|
||||
#
|
||||
# FMain
|
||||
#
|
||||
$FMain.BackColor = [System.Drawing.SystemColors]::ControlText
|
||||
$FMain.ClientSize = New-Object System.Drawing.Size(800, 450)
|
||||
$FMain.Controls.Add($tabs)
|
||||
$FMain.Controls.Add($menuStrip1)
|
||||
$FMain.ForeColor = [System.Drawing.Color]::Black
|
||||
$FMain.MainMenuStrip = $menuStrip1
|
||||
$FMain.Name = "FMain"
|
||||
$FMain.Text = "SharePoint Utils GUI"
|
||||
|
||||
#Onglet Move
|
||||
##Lister les sites dans les comboBoxes
|
||||
$BlistSites.Add_Click({
|
||||
|
||||
$jobListSP = Start-Job -ScriptBlock {
|
||||
|
||||
#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")
|
||||
}
|
||||
}
|
||||
|
||||
if ($jobListSP.State -eq "Completed") {
|
||||
$resultListSP = Receive-Job -Job $jobListSP
|
||||
$button.Invoke({
|
||||
$button.Text = "Terminé"
|
||||
$textBox.Text = $resultListSP
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
##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({
|
||||
|
||||
|
||||
$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
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
|
||||
#Onglet Parametres
|
||||
##Connexion Sharepoint
|
||||
$pnpConnection=$null
|
||||
$pnpConnection = Get-PnPConnection | Out-string
|
||||
$tenantURL = $URLTenant.Text
|
||||
|
||||
$BconnectSP.Add_Click({
|
||||
Disconnect-PnPOnline
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
|
||||
function OnFormClosing_FMain{
|
||||
# $this parameter is equal to the sender (object)
|
||||
# $_ is equal to the parameter e (eventarg)
|
||||
|
||||
# The CloseReason property indicates a reason for the closure :
|
||||
# if (($_).CloseReason -eq [System.Windows.Forms.CloseReason]::UserClosing)
|
||||
|
||||
#Sets the value indicating that the event should be canceled.
|
||||
($_).Cancel= $False
|
||||
}
|
||||
|
||||
$FMain.Add_FormClosing({
|
||||
#Disconnect-PnPOnline
|
||||
Write-Host "Goodbye, come again soon :*"
|
||||
OnFormClosing_FMain
|
||||
})
|
||||
|
||||
$FMain.Add_Shown({$FMain.Activate()})
|
||||
$ModalResult=$FMain.ShowDialog()
|
||||
# Libération de la Form
|
||||
$FMain.Dispose()
|
|
@ -1,4 +0,0 @@
|
|||
# Scripts Sharepoint
|
||||
|
||||
- [Verifier la taille des corbeilles du Sharepoint](https://git.azuze.fr/kawa/ps-scripts/src/branch/main/Sharepoint/sharepoint-taille-trash.ps1)
|
||||
- [Nettoyer toutes les versions de fichier en conservant les 5 dernieres](https://git.azuze.fr/kawa/ps-scripts/src/branch/main/Sharepoint/SP-empty.ps1)
|
|
@ -1,11 +0,0 @@
|
|||
#On rentre l'URL du site Sharepoint
|
||||
$SiteURL = Read-Host -Prompt "Entrez l'URL du site "
|
||||
|
||||
#On s'y connecte
|
||||
Connect-PnPOnline -Url $SiteURL -Credentials (Get-Credential)
|
||||
|
||||
#On additionne la taille de tous les objets de la corbeille
|
||||
$RecycleBinSize = Get-PnPRecycleBinItem -RowLimit 500000 | Where-Object { $_.ItemState -eq "FirstStage" }| Measure-Object -Property Size -Sum
|
||||
|
||||
#On recupere la taille en format lisible
|
||||
Write-host "Recycle Bin Size (GB):" ([Math]::Round($RecycleBinSize.Sum/1GB,2))
|
|
@ -1,29 +0,0 @@
|
|||
# On verifie quelle version est installée
|
||||
if (Test-Path "C:\Program Files\Mozilla Firefox\firefox.exe") {
|
||||
$installedVersion = (Get-ItemProperty "HKLM:\Software\Mozilla\Mozilla Firefox" -Name "CurrentVersion").CurrentVersion
|
||||
Write-Host "Version installee: $installedVersion"
|
||||
} else {
|
||||
Write-Host "Firefox n'est pas installe."
|
||||
}
|
||||
|
||||
# On récupère la dernière version
|
||||
$r = Invoke-WebRequest -Uri "https://www.mozilla.org/fr-FR/firefox/new/"
|
||||
$latestVersion = $r.Content.Split([Environment]::NewLine) | Select-String 'data-latest-firefox' |
|
||||
ForEach-Object { $_.ToString().Split('"')[9] }
|
||||
|
||||
# On fait le comparo entre la version installée et la dernière disponible
|
||||
if ($installedVersion -lt $latestVersion) {
|
||||
Write-Host "Nouvelle version disponible: $latestVersion"
|
||||
|
||||
# On DL la nouvelle version
|
||||
$url = "https://download.mozilla.org/?product=firefox-latest-ssl&os=win64&lang=fr-FR"
|
||||
$output = "C:\Users\$env:USERNAME\Downloads\FirefoxSetup.exe"
|
||||
Invoke-WebRequest -Uri $url -OutFile $output
|
||||
|
||||
# On installe silencieusement
|
||||
Start-Process -FilePath $output -ArgumentList "/S" -Wait
|
||||
|
||||
Write-Host "Firefox a bien ete passe en version $latestVersion."
|
||||
} else {
|
||||
Write-Host "Firefox est a jour. Version: $installedVersion"
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
#On recupere la liste des peripheriques biometriques
|
||||
Get-PnpDevice -PresentOnly -Class Biometric
|
|
@ -1,25 +0,0 @@
|
|||
#On demande à l'user de rentrer le chemin source
|
||||
$entPath = Read-Host "Chemin vers le dossier a examiner : "
|
||||
|
||||
#et le chemin cible
|
||||
$outPath = Read-Host "Ou stocker le CSV : "
|
||||
|
||||
#On active la recursion
|
||||
$FolderPath = dir -Directory -Path "$entPath" -Recurse -Force
|
||||
|
||||
$Report = @()
|
||||
|
||||
#Une petite boucle pour recuperer les ACL de tous les dossiers
|
||||
Foreach ($Folder in $FolderPath) {
|
||||
$Acl = Get-Acl -Path $Folder.FullName
|
||||
foreach ($Access in $acl.Access)
|
||||
{
|
||||
$Properties = [ordered]@{'FolderName'=$Folder.FullName;'AD
|
||||
Group or
|
||||
User'=$Access.IdentityReference;'Permissions'=$Access.FileSystemRights;'Inherited'=$Access.IsInherited}
|
||||
$Report += New-Object -TypeName PSObject -Property $Properties
|
||||
}
|
||||
}
|
||||
|
||||
#On stocke le rapport la ou l'user veut
|
||||
$Report | Export-Csv -path "$outPath"
|
Loading…
Reference in New Issue