Skip to content

Instantly share code, notes, and snippets.

View HiteaFR's full-sized avatar
💪
Focusing

Hitéa HiteaFR

💪
Focusing
View GitHub Profile
@HiteaFR
HiteaFR / robocopy_doc.bat
Created September 26, 2023 20:30
Copier des fichiers avec Robocopy et Powershell - Doc
robocopy "Source" "DEST" /MIR /NDL /NP /FFT /Z /R:3 /W:10 /LOG+:C:\Log.txt
/mir Reflète une arborescence de répertoires (équivalent à /e plus /purge)
/ndl Spécifie que les noms des répertoires ne doivent pas être journalisés.
/np Spécifie que la progression de l’opération de copie (le nombre de fichiers ou de répertoires copiés jusqu’à présent) ne s’affiche pas.
/fft Suppose l’heure des fichiers FAT (précision de deux secondes).
/z Copie les fichiers en mode redémarrable.
/r : <N > Spécifie le nombre de nouvelles tentatives en cas d’échec de copies. La valeur par défaut de N est 1 million (1 million nouvelles tentatives).
/w : <N > Spécifie le délai d’attente entre les tentatives, en secondes. La valeur par défaut de N est 30 (temps d’attente de 30 secondes).
@HiteaFR
HiteaFR / robocopy_exemple.bat
Created September 26, 2023 20:27
Copier des fichiers avec Robocopy et Powershell
@echo off
net use * /delete /yes
net use p: \\COMPUTER_NAME\d$\... /user:USER PASSWORD
robocopy "P:" "DEST" /MIR /NDL /NP /FFT /Z /R:3 /W:10 /LOG+:C:\Log.txt
net use * /delete /yes
@HiteaFR
HiteaFR / AZ_Storage_Lenght.ps1
Created September 26, 2023 20:23
Calculer la taille totale d’un conteneur de stockage Azure
# this script will show how to get the total size of the blobs in a container
# before running this, you need to create a storage account, create a container,
# and upload some blobs into the container
# note: this retrieves all of the blobs in the container in one command.
# if you are going to run this against a container with a lot of blobs
# (more than a couple hundred), use continuation tokens to retrieve
# the list of blobs.
# these are for the storage account to be used
$resourceGroup = ""
@HiteaFR
HiteaFR / AZ_Copy_PST.bat
Created September 26, 2023 20:22
Migrer des PST vers Exchange Online avec AZCopy
cd "C:\Program Files (x86)\Microsoft SDKs\Azure\AzCopy"
$PSTFile = "\\SRV01\PSTImport"
$AzureStore = "AZ_BLOB_URL"
$LogFile = "C:\importPST.txt"
& .\AzCopy.exe /Source:$PSTFile /Dest:$AzureStore /V:$LogFile /Y
@HiteaFR
HiteaFR / Windows-Srv_Reinstall_Feature.ps1
Created September 26, 2023 20:15
Ré-installer une fonctionnalité Windows Serveur supprimée
# Example for Windows Backup Feature
# Get info for the desired Feature
Dism /online /Get-FeatureInfo /FeatureName:WindowsServerBackup
# Mount an WinSxs folder from other server with net use. You can use credentials
net use p: \\SERVER_PATH\c$\Windows\WinSxS /user:USERNAME PASSWORD
# Finally, you can restore the feature
DISM /Online /Enable-Feature /FeatureName:WindowsServerBackup /All /LimitAccess /Source:P:
@HiteaFR
HiteaFR / AD_Time_Config.bat
Created September 26, 2023 20:13
Configurer le NTP d'un contrôleur de domaine
#For DC on Hyper-V, Disable the TimeSync service.
#On DC
w32tm /config /update /manualpeerlist:"time.windows.com,0x8" /syncfromflags:MANUAL
Restart-Service w32time
#Verify on DC and Computer
w32tm /query /source
w32tm /resync
w32tm /query /status
@HiteaFR
HiteaFR / AD_Create_Home_Folder.ps1
Created September 26, 2023 20:11
Créer des dossiers personnels dans un domaine avec Powershell
$OU_path = "OU_PATH"
$Base_Folder = "RUN_FOLDER"
$users = get-aduser -SearchBase $OU_path -filter * -Properties UserPrincipalName | % { $_.UserPrincipalName.Split('@')[0] }
$users | ForEach {
$folder = join-path -path $Base_Folder -childpath $_
If (!(Test-Path -Path $folder )) {
@HiteaFR
HiteaFR / Set_Network_Location.ps1
Created September 26, 2023 20:08
Changer la catégorie d'un réseau en Powershell (Public, Privée, Domaine)
#Droits admin nécessaire
#Afficher le profil actif
$ProfileName = Get-NetConnectionProfile
# Changer la catégorie du profil actif (valeurs acceptées : Public, Private, DomainAuthenticated)
Set-NetConnectionProfile -Name $ProfileName.Name -NetworkCategory Private
@HiteaFR
HiteaFR / Windows_Backup_Task.ps1
Last active September 26, 2023 20:02
WSB rapport sur Microsoft Teams (Webhook)
$jobname = "Windows_Backup_Teams"
$action = New-ScheduledTaskAction –Execute "@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -ExecutionPolicy Bypass -File C:\Windows_Backup_Teams_Report.ps1"
$trigger = New-ScheduledTaskTrigger -daily -At 7am
$settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -StartWhenAvailable -DontStopOnIdleEnd
Register-ScheduledTask -TaskName $jobname -Action $action -Trigger $trigger -RunLevel Highest -Settings $settings
@HiteaFR
HiteaFR / Ksos_Start_Stop.bat
Created September 26, 2023 19:52
WSB backup erreur Kaspersky 2019
@echo off
"C:\Program Files (x86)\Kaspersky Lab\Kaspersky Small Office Security 17.0.0\avp.com" EXIT /password=BugK@sos2019
"C:\Program Files (x86)\Kaspersky Lab\Kaspersky Small Office Security 17.0.0\avp.com" START /password=BugK@sos2019