diff --git a/Intune/UpdateForensITXML-ProfWiz.ps1 b/Intune/UpdateForensITXML-ProfWiz.ps1 new file mode 100644 index 0000000..724d04d --- /dev/null +++ b/Intune/UpdateForensITXML-ProfWiz.ps1 @@ -0,0 +1,89 @@ +# 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" + diff --git a/Sharepoint/sharepoint-taille-trash.ps1 b/Sharepoint/sharepoint-taille-trash.ps1 new file mode 100644 index 0000000..ca497b8 --- /dev/null +++ b/Sharepoint/sharepoint-taille-trash.ps1 @@ -0,0 +1,11 @@ +#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)) \ No newline at end of file diff --git a/Windows/FirefoxAutoUpdate.ps1 b/Windows/FirefoxAutoUpdate.ps1 new file mode 100644 index 0000000..22522e1 --- /dev/null +++ b/Windows/FirefoxAutoUpdate.ps1 @@ -0,0 +1,29 @@ +# 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" +} \ No newline at end of file diff --git a/Windows/get-bio.ps1 b/Windows/get-bio.ps1 new file mode 100644 index 0000000..6c29afe --- /dev/null +++ b/Windows/get-bio.ps1 @@ -0,0 +1,2 @@ +#On recupere la liste des peripheriques biometriques +Get-PnpDevice -PresentOnly -Class Biometric \ No newline at end of file diff --git a/Windows/getAcl.ps1 b/Windows/getAcl.ps1 new file mode 100644 index 0000000..58c0c0d --- /dev/null +++ b/Windows/getAcl.ps1 @@ -0,0 +1,25 @@ +#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" \ No newline at end of file