diff --git a/SysAdmin-Toolbox.ps1 b/SysAdmin-Toolbox.ps1 new file mode 100644 index 0000000..fde80f1 --- /dev/null +++ b/SysAdmin-Toolbox.ps1 @@ -0,0 +1,534 @@ +##[Ps1 To Exe] +## +##Kd3HDZOFADWE8uO1 +##Nc3NCtDXTlaDjofG5iZk2UriT2cXQcuenaSu0oT8sqrNlxHwbqg7fGRLvyT9A06uZeaxnPm2fdIZVA8tKv8O7KaeEuSmJQ== +##Kd3HFJGZHWLWoLaVvnQnhQ== +##LM/RF4eFHHGZ7/K1 +##K8rLFtDXTiW5 +##OsHQCZGeTiiZ4NI= +##OcrLFtDXTiW5 +##LM/BD5WYTiiZ4tI= +##McvWDJ+OTiiZ4tI= +##OMvOC56PFnzN8u+Vs1Q= +##M9jHFoeYB2Hc8u+VslQ= +##PdrWFpmIG2HcofKIo2QX +##OMfRFJyLFzWE8uO1 +##KsfMAp/KUzWI0g== +##OsfOAYaPHGbQvbyVvnQmqxKgEiZ7Dg== +##LNzNAIWJGmPcoKHc7Do3uAu/DDFlPovL2Q== +##LNzNAIWJGnvYv7eVvnRWyX/HYUkbLvG0lpqF67nc +##M9zLA5mED3nfu77Q7TV64AuzAgg= +##NcDWAYKED3nfu77Q7TV64AuzAgg= +##OMvRB4KDHmHQvbyVvnQX +##P8HPFJGEFzWE8pP51x1UxHuO +##KNzDAJWHD2fS8u+Vgw== +##P8HSHYKDCX3N8u+VwhhDzGjPcih5PpfJ2Q== +##LNzLEpGeC3fMu77Ro2k3hQ== +##L97HB5mLAnfMu77Ro2k3hQ== +##P8HPCZWEGmaZ7/K1 +##L8/UAdDXTlaDjofG5iZk2UriT2cXT+mvkJGV67SMw8vAjwz6aKpUenFFoADfIXj9FLI6WuEZvd8UFTQkKeAKov+QM+i9SasEl6NWZeOcp44LFEndo7f70AyfypPUHwVwU2DdYwGRAS6bZ6GdRHiOgIh6uUK5Rsfiqo4rgVSX234vzndhMp61tRh337ou6rLCp23MdKiJfA== +##Kc/BRM3KXxU= +## +## +##fd6a9f26a06ea3bc99616d4851b372ba +$host.ui.RawUI.WindowTitle = "SysAdmin Toolbox v2.0 (27/12/2022) - contact : alexandre@alexandremottier.fr" +$dom = $env:userdomain +$usr = $env:username +$DisplayName = ([adsi]"WinNT://$dom/$usr,user").fullname +Write-Host -ForegroundColor Yellow "Bonjour et bienvenue sur SysAdmin Toolbox, $DisplayName !" +While (0 -lt 1) +{ + Write-Host "" + Write-Host -ForegroundColor Yellow "..:: Mots de passe ::.." + Write-Host "" + Write-Host "1. Vérifier un mot de passe Active Directory" + Write-Host "3. Lister les mots de passe Active Directory expirés" + Write-Host "4. Générateur de mots de passe" + Write-Host "" + Write-Host -ForegroundColor Yellow "..:: Serveurs ::.." + Write-Host "" + Write-Host "5. Lister les utilisateurs d'un broker RDS" + Write-Host "6. Mettre le serveur à l'heure via pool.ntp.org" + Write-Host "7. Programmer un redémarrage" + Write-Host "8. Programmer un arrêt" + Write-Host "9. Lister les contrôleurs de domaine d'un serveur" + Write-Host "" + Write-Host -ForegroundColor Yellow "..:: Autres outils ::.." + Write-Host "" + Write-Host "10. Récupérer des informations sur la passerelle réseau et le FAI" + Write-Host "11. Nettoyer les caches des navigateurs (Chrome, Firefox, IE, Edge)" + Write-Host "12. Lister les serveurs de messagerie d'un domaine" + Write-Host "13. Calculer l'espace minimal nécessaire pour les clichés instantanés" + Write-Host "14. Purger les téléchargements de tous les utilisateurs sur une machine" + Write-Host "15. Générer les exclusions SQL Last Backup (Nouveau !)" + Write-Host "16. Port d'administration des UTM (BETA)" + Write-Host "17. Lancer TreeSizeFree (téléchargement de la dernière version)" + Write-Host "" + + $choice = Read-Host "Faites votre choix parmi les options ci-dessus (q pour quitter)" + + #Choix 1 + if($choice -eq 1) + { + Write-Host -ForegroundColor Yellow "...::: Outil de vérification de mot de passe Active Directory :::..." + Write-Host "" + While(0 -lt 1) + { + Function Test-ADAuthentication { + param($username,$password) + (new-object directoryservices.directoryentry "",$username,$password).psbase.name -ne $null + } + $login = Read-Host "Quel est l'identifiant de la session ? (q pour quitter)" + + if ($login -eq "q") { + break + } + + $password = Read-Host "Quel est le mot de passe de la session ?"-AsSecureString + + $password = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($password) + $password = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($password) + + $result = Test-ADAuthentication "$login" "$password" + + If($result -eq "True") + { + Write-Host -ForegroundColor Green "Le mot de passe AD est correct !" + } + else + { + Write-Host -ForegroundColor Red "Le mot de passe AD est incorrect." + } + } + } + + if($choice -eq 2) + { + Write-Host -ForegroundColor Yellow "...::: Outil de vérification de mot de passe Microsoft 365 :::..." + Write-Host "" + + $Credential = Get-Credential + Write-Host -ForegroundColor Yellow "Test de connexion en cours... " -NoNewline + $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $Credential -Authentication Basic -AllowRedirection + Import-PSSession $Session + + if ($Error.Count -eq 0) { + Write-Host -ForegroundColor Green "Connexion OK !" + } + else + { + Write-Host -ForegroundColor Red "Erreur de connexion ! Le mot de passe est-il correct ?" + } + + Remove-PSSession $Session + pause + } + + if($choice -eq 3) + { + Write-Host -ForegroundColor Yellow "...::: Liste des comptes Active Directory ayant un mot de passe expiré et ayant été modifié il y a moins de 6 mois :::..." + Write-Host "" + $LowerDate = $((Get-Date).AddDays(-180)) + Get-ADUser -filter * -properties PasswordLastSet, PasswordExpired, PasswordNeverExpires | Where-Object -Property Enabled -EQ "True" | Where-Object -Property PasswordExpired -EQ $True | Where-Object -Property PasswordLastSet -gt "$LowerDate" | Sort-Object -Property Name | ft Name,SamAccountName,PasswordLastSet + pause + } + + if($choice -eq 4) + { + Write-Host -ForegroundColor Yellow "...::: Générateur de mot de passe :::..." + Write-Host "" + # Arrays definition + $minuscule = @('alpha','bravo','charlie','delta','echo','foxtrot','golf','hotel','india','juliette','kilo','lima','mike','november','oscar','papa','quebec','romeo','sierra','tango','uniform','victor','whisky','yankee','xray','zulu') + $majuscule = @('ALPHA','BRAVO','CHARLIE','DELTA','ECHO','FOXTROT','GOLF','HOTEL','INDIA','JULIETTE','KILO','LIMA','MIKE','NOVEMBER','OSCAR','PAPA','QUEBEC','ROMEO','SIERRA','TANGO','UNIFORM','VICTOR','WHISKY','YANKEE','XRAY','ZULU') + $symbol = @('@','+','-','&') + While ($reponse4 -ne "q") + { + # Select random object + $min = Get-Random -InputObject $minuscule -Count 1 + $maj = Get-Random -InputObject $majuscule -Count 1 + $num = Get-Random -Maximum 99 + $sym = Get-Random -InputObject $symbol -Count 1 + + Write-Host "$min$maj$sym$num" -ForegroundColor Green + $reponse4 = Read-Host "Appuyez sur q pour quitter ou sur Entrée pour générer un nouveau mot de passe." + } + } + + if($choice -eq 5) + { + Write-Host -ForegroundColor Yellow "...::: Listage des sessions d'un broker RDS :::..." + Write-Host "" + Import-Module RemoteDesktop + Get-RDUserSession | sort UserName | ft UserName,SamAccountName,HostServer + pause + } + + if($choice -eq 6) + { + Write-Host -ForegroundColor Yellow "...::: Mise à l'heure du serveur :::..." + Write-Host "" + Write-Host -ForegroundColor Yellow -NoNewline "Modification du serveur de synchronisation en fr.pool.ntp.org... " + w32tm /config /syncfromflags:MANUAL /manualpeerlist:"fr.pool.ntp.org" | Out-Null + + if($Error.Count -ne 0) + { + Write-Host -ForegroundColor DarkRed "Erreur !" + Write-Host -ForegroundColor DarkRed $error[0] + break + } + else + { + Write-Host -ForegroundColor Green "OK" + } + Write-Host -NoNewline -ForegroundColor Yellow "Redémarrage du service w32time... " + net stop w32time | Out-Null + net start w32time | Out-Null + + if($Error.Count -ne 0) #Si on a une erreur + { + Write-Host -ForegroundColor DarkRed "Erreur :" + Write-Host -ForegroundColor DarkRed $error[0] + break + } + else + { + Write-Host -ForegroundColor Green "OK" + } + Write-Host -ForegroundColor Yellow -NoNewline "Resynchronisation de l'heure... " + w32tm /resync | Out-Null + + if($Error.Count -ne 0) + { + Write-Host -ForegroundColor DarkRed "Erreur : " + Write-Host -ForegroundColor DarkRed $error[0] + break + } + else + { + Write-Host -ForegroundColor Green "OK" + } + w32tm /query /status | Write-Host + pause + } + + if($choice -eq 7) +{ + Write-Host -ForegroundColor Yellow "...::: Planification d'un redémarrage :::..." + Write-Host "" + $RebootTime = 0 + while($RebootTime -eq 0) { + + $RebootTime = Read-Host "Indiquez la date et heure de redémarrage au format JJ/MM/AAAA HH:MM (q pour quitter)" + + if($RebootTime -eq "q") + { + break + } + + $Seconds = (New-TimeSpan -Start $(Get-Date -UFormat "%d/%m/%Y %R") -End "$RebootTime").TotalSeconds + Write-Host -ForegroundColor Yellow "Commande générée :" + Write-Host "shutdown /r /f /t $Seconds" + } + sleep 10 +} + +if($choice -eq 8) +{ + Write-Host -ForegroundColor Yellow "...::: Planification d'un arrêt :::..." + Write-Host "" + $ShutdownTime = 0 + while($ShutdownTime -eq 0) { + + $ShutdownTime = Read-Host "Indiquez la date et heure d'arrêt au format JJ/MM/AAAA HH:MM (q pour quitter)" + + if($ShutdownTime -eq "q") + { + break + } + + $Seconds = (New-TimeSpan -Start $(Get-Date -UFormat "%d/%m/%Y %R") -End "$ShutdownTime").TotalSeconds + Write-Host -ForegroundColor Yellow "Commande générée :" + Write-Host "shutdown /s /f /t $Seconds" + } + sleep 10 +} + +if($choice -eq 9) +{ + Write-Host -ForegroundColor Yellow "...::: Contrôleurs de domaine de cette machine :::..." + Write-Host "" + $DomainControllers = ((Get-ADForest).GlobalCatalogs) + echo $DomainControllers + + sleep 10 +} + + + if($choice -eq 10) + { + Write-Host -ForegroundColor Yellow "...::: Récupération d'informations sur passerelle réseau :::..." + Write-Host "" + $IP = (Get-WmiObject Win32_NetworkAdapterConfiguration | Where-Object {$_.IPEnabled}).DefaultIPGateway + $MACAddressList = (Get-NetNeighbor -State Reachable) + foreach ($item in $MACAddressList) + { + $AdresseIP = $item.IPAddress + $AdresseMAC = $item.LinkLayerAddress + if ($IP -contains $AdresseIP){$GatewayMac = $AdresseMAC ; $GatewayIP = $AdresseIP} + } + + $PublicIP = ((Resolve-DnsName -Name myip.opendns.com -Server resolver1.opendns.com).IPAddress) + + $MacSplit = $GatewayMac -split "-" + $MacPrefix = $MacSplit[0] + "-" + $MacSplit[1] + "-" + $MacSplit[2] + + $Router = (Invoke-WebRequest -Uri "https://api.macvendors.com/$MacPrefix").Content + + $ShodanLink = "https://api.shodan.io/shodan/host/" + $PublicIP + "?key=9r6vVczYqYGR9F3WADASttMPt6fqK2Mm" + $Shodan = Invoke-RestMethod -uri $ShodanLink + $ISP = $Shodan.isp + if ($Router -eq "") + { + Write-Host "Gateway vendor is unknown ($GatewayMac). `nLocal IP is $AdresseIP. `nPublic IP is $PublicIP." + } + else + { + Write-Host "Gateway vendor is $Router ($GatewayMac). `nLocal IP is $AdresseIP. `nPublic IP is $PublicIP ($ISP)." + } + sleep 10 + } + + if($choice -eq 11) + { + Write-Host -ForegroundColor Yellow "...::: Nettoyage des caches de navigateurs :::..." + Write-Host "" + sleep 1 + Write-Host -ForegroundColor Green "Récupération des utilisateurs`n" + $Users = Get-ChildItem "C:\Users" | Select-Object Name + $users = $Users.Name + + # Begin! + sleep 1 + Write-Host -ForegroundColor Yellow "Lancement du nettoyage`n" + sleep 1 + # Clear Firefox Cache + Write-Host -ForegroundColor Yellow "Nettoyage du cache de Firefox`n" + Foreach ($user in $Users) { + if (Test-Path "C:\Users\$user\AppData\Local\Mozilla\Firefox\Profiles") { + Remove-Item -Path "C:\Users\$user\AppData\Local\Mozilla\Firefox\Profiles\*\cache\*" -Recurse -Force -ErrorAction SilentlyContinue -Verbose + Remove-Item -Path "C:\Users\$user\AppData\Local\Mozilla\Firefox\Profiles\*\cache2\entries\*" -Recurse -Force -ErrorAction SilentlyContinue -Verbose + Remove-Item -Path "C:\Users\$user\AppData\Local\Mozilla\Firefox\Profiles\*\thumbnails\*" -Recurse -Force -ErrorAction SilentlyContinue -Verbose + Remove-Item -Path "C:\Users\$user\AppData\Local\Mozilla\Firefox\Profiles\*\cookies.sqlite" -Recurse -Force -ErrorAction SilentlyContinue -Verbose + Remove-Item -Path "C:\Users\$user\AppData\Local\Mozilla\Firefox\Profiles\*\webappsstore.sqlite" -Recurse -Force -ErrorAction SilentlyContinue -Verbose + Remove-Item -Path "C:\Users\$user\AppData\Local\Mozilla\Firefox\Profiles\*\chromeappsstore.sqlite" -Recurse -Force -ErrorAction SilentlyContinue -Verbose + Remove-Item -Path "C:\Users\$user\AppData\Local\Mozilla\Firefox\Profiles\*\OfflineCache\*" -Recurse -Force -ErrorAction SilentlyContinue -Verbose + } + Write-Host -ForegroundColor Green "OK pour $user`n" + } + # Clear Google Chrome + sleep 1 + Write-Host -ForegroundColor Yellow "Nettoyage du cache de Google Chrome`n" + Foreach ($user in $Users) { + if (Test-Path "C:\Users\$user\AppData\Local\Google\Chrome\User Data") { + Remove-Item -Path "C:\Users\$user\AppData\Local\Google\Chrome\User Data\Default\Cache\*" -Recurse -Force -ErrorAction SilentlyContinue -Verbose + Remove-Item -Path "C:\Users\$user\AppData\Local\Google\Chrome\User Data\Default\Cache2\entries\*" -Recurse -Force -ErrorAction SilentlyContinue -Verbose + Remove-Item -Path "C:\Users\$user\AppData\Local\Google\Chrome\User Data\Default\Cookies" -Recurse -Force -ErrorAction SilentlyContinue -Verbose + Remove-Item -Path "C:\Users\$user\AppData\Local\Google\Chrome\User Data\Default\Media Cache" -Recurse -Force -ErrorAction SilentlyContinue -Verbose + Remove-Item -Path "C:\Users\$user\AppData\Local\Google\Chrome\User Data\Default\Cookies-Journal" -Recurse -Force -ErrorAction SilentlyContinue -Verbose + Remove-Item -Path "C:\Users\$user\AppData\Local\Google\Chrome\User Data\Default\JumpListIconsOld" -Recurse -Force -ErrorAction SilentlyContinue -Verbose + # Comment out the following line to remove the Chrome Write Font Cache too. + # Remove-Item -Path "C:\Users\$user\AppData\Local\Google\Chrome\User Data\Default\ChromeDWriteFontCache" -Recurse -Force -ErrorAction SilentlyContinue -Verbose + + # Check Chrome Profiles. It looks as though when creating profiles, it just numbers them Profile 1, Profile 2 etc. + $Profiles = Get-ChildItem -Path "C:\Users\$user\AppData\Local\Google\Chrome\User Data" | Select-Object Name | Where-Object Name -Like "Profile*" + foreach ($Account in $Profiles) { + $Account = $Account.Name + Remove-Item -Path "C:\Users\$user\AppData\Local\Google\Chrome\User Data\$Account\Cache\*" -Recurse -Force -ErrorAction SilentlyContinue -Verbose + Remove-Item -Path "C:\Users\$user\AppData\Local\Google\Chrome\User Data\$Account\Cache2\entries\*" -Recurse -Force -ErrorAction SilentlyContinue -Verbose + Remove-Item -Path "C:\Users\$user\AppData\Local\Google\Chrome\User Data\$Account\Cookies" -Recurse -Force -ErrorAction SilentlyContinue -Verbose + Remove-Item -Path "C:\Users\$user\AppData\Local\Google\Chrome\User Data\$Account\Media Cache" -Recurse -Force -ErrorAction SilentlyContinue -Verbose + Remove-Item -Path "C:\Users\$user\AppData\Local\Google\Chrome\User Data\$Account\Cookies-Journal" -Recurse -Force -ErrorAction SilentlyContinue -Verbose + Remove-Item -Path "C:\Users\$user\AppData\Local\Google\Chrome\User Data\$Account\JumpListIconsOld" -Recurse -Force -ErrorAction SilentlyContinue -Verbose + } + } + Write-Host -ForegroundColor Green "OK pour $user`n" + } + + # Clear Internet Explorer & Edge + sleep 1 + Write-Host -ForegroundColor Yellow "Nettoyage du cache d'Internet Explorer`n" + Foreach ($user in $Users) { + Remove-Item -Path "C:\Users\$user\AppData\Local\Microsoft\Windows\Temporary Internet Files\*" -Recurse -Force -ErrorAction SilentlyContinue -Verbose + Remove-Item -Path "C:\Users\$user\AppData\Local\Microsoft\Windows\INetCache\* " -Recurse -Force -ErrorAction SilentlyContinue -Verbose + Remove-Item -Path "C:\Users\$user\AppData\Local\Microsoft\Windows\WebCache\* " -Recurse -Force -ErrorAction SilentlyContinue -Verbose + } + Write-Host -ForegroundColor Green "OK pour $user`n" + + # Clear Edge Chromium + sleep 1 + Write-Host -ForegroundColor Yellow "Nettoyage du cache de Microsoft Edge`n" + # taskkill /F /IM msedge.exe + Foreach ($user in $Users) { + if (Test-Path "C:\Users\$user\AppData\Local\Microsoft\Edge\User Data") { + Remove-Item -Path "C:\Users\$user\AppData\Local\Microsoft\Edge\User Data\Default\Cache\*" -Recurse -Force -ErrorAction SilentlyContinue -Verbose + #Remove-Item -Path "C:\Users\$user\AppData\Local\Microsoft\Edge\User Data\Default\Cache2\entries\*" -Recurse -Force -ErrorAction SilentlyContinue -Verbose + Remove-Item -Path "C:\Users\$user\AppData\Local\Microsoft\Edge\User Data\Default\Cookies" -Recurse -Force -ErrorAction SilentlyContinue -Verbose + #Remove-Item -Path "C:\Users\$user\AppData\Local\Microsoft\Edge\User Data\Default\Media Cache" -Recurse -Force -ErrorAction SilentlyContinue -Verbose + Remove-Item -Path "C:\Users\$user\AppData\Local\Microsoft\Edge\User Data\Default\Cookies-Journal" -Recurse -Force -ErrorAction SilentlyContinue -Verbose + #Remove-Item -Path "C:\Users\$user\AppData\Local\Microsoft\Edge\User Data\Default\JumpListIconsOld" -Recurse -Force -ErrorAction SilentlyContinue -Verbose + # Comment out the following line to remove the Edge Write Font Cache too. + # Remove-Item -Path "C:\Users\$user\AppData\Local\Microsoft\Edge\User Data\Default\EdgeDWriteFontCache" -Recurse -Force -ErrorAction SilentlyContinue -Verbose + + # Check Edge Profiles. It looks as though when creating profiles, it just numbers them Profile 1, Profile 2 etc. + $Profiles = Get-ChildItem -Path "C:\Users\$user\AppData\Local\Microsoft\Edge\User Data" | Select-Object Name | Where-Object Name -Like "Profile*" + foreach ($Account in $Profiles) { + $Account = $Account.Name + Remove-Item -Path "C:\Users\$user\AppData\Local\Microsoft\Edge\User Data\$Account\Cache\*" -Recurse -Force -ErrorAction SilentlyContinue -Verbose + #Remove-Item -Path "C:\Users\$user\AppData\Local\Microsoft\Edge\User Data\$Account\Cache2\entries\*" -Recurse -Force -ErrorAction SilentlyContinue -Verbose + Remove-Item -Path "C:\Users\$user\AppData\Local\Microsoft\Edge\User Data\$Account\Cookies" -Recurse -Force -ErrorAction SilentlyContinue -Verbose + #Remove-Item -Path "C:\Users\$user\AppData\Local\Microsoft\Edge\User Data\$Account\Media Cache" -Recurse -Force -ErrorAction SilentlyContinue -Verbose + Remove-Item -Path "C:\Users\$user\AppData\Local\Microsoft\Edge\User Data\$Account\Cookies-Journal" -Recurse -Force -ErrorAction SilentlyContinue -Verbose + #Remove-Item -Path "C:\Users\$user\AppData\Local\Microsoft\Edge\User Data\$Account\JumpListIconsOld" -Recurse -Force -ErrorAction SilentlyContinue -Verbose + } + } + Write-Host -ForegroundColor Green "OK pour $user`n" + + } + Write-Host -ForegroundColor Green "Nettoyage des navigateurs terminé !" + sleep 3 + } + if($choice -eq 12) + { + Write-Host -ForegroundColor Yellow "...::: Récupération des enregistrements MX pour un domaine DNS :::..." + Write-Host "" + While (0 -lt 1){ + $domain = Read-Host "Entrez le nom du domaine à vérifier (q pour quitter)" + + if($domain -eq "q") { + break + } + + Resolve-DnsName -Name $domain -Type MX | sort Preference -desc | ft Name,NameExchange,Preference + } + } + if($choice -eq 13) + { + Write-Host -ForegroundColor Yellow "...::: Calcul d'espace minimal pour cliché instantané :::..." + Write-Host "" + While (0 -lt 1){ + $TailleVolume = Read-Host "Indiquez la taille du volume concerné (en Go) (q pour quitter)" + + if($TailleVolume -eq "q") { + break + } + + $TailleVSS = ($TailleVolume/100)*5 + $TailleMo = ($TailleVSS*1024) + Write-Host "Il faut allouer au moins $TailleVSS Go ($TailleMo Mo) au VSS sur ce lecteur (5% de $TailleVolume Go)." + sleep 5 + } + } + if($choice -eq 14) + { + Write-Host -ForegroundColor Yellow "...::: Purger les téléchargements pour tous les utilisateurs :::..." + Write-Host "" + $delai = Read-Host "Quel doit être l'âge maximal des fichiers du dossier ? (en jours)" + $limit = (Get-Date).AddDays(-$delai) + $users = get-childitem c:\users + foreach ($user in $users) + { + Get-ChildItem -Path C:\Users\$user\Downloads\* -Recurse -Force | Where-Object { !$_.PSIsContainer -and $_.CreationTime -lt $limit } | Remove-Item -Force -Erroraction silentlycontinue + Get-ChildItem -Path C:\Users\$user\Downloads\* -Recurse -Force | Where-Object { $_.PSIsContainer -and (Get-ChildItem -Path $_.FullName -Recurse -Force | Where-Object { !$_.PSIsContainer }) -eq $null } | Remove-Item -Force -Recurse + } + Write-Host -ForegroundColor Green "OK !" + sleep 5 + } + if($choice -eq 15) + { + Write-Host -ForegroundColor Yellow "...::: SQL Last Backup - Générateur de paramètre exclusion :::..." + Write-Host "" + $Instance = Read-Host "Tapez le nom de l'instance " + $Base = New-Object System.Collections.ArrayList + $AddBase = Read-Host "Tapez le nom de la base (possibilité de coller le contenu params récupéré depuis la vérification Ninja, ATTENTION A NE PAS COPIER LE NOM DE L'INSTANCE DANS LES PARAMS !) " + $Base = $Base + ($AddBase -replace(' ','-espace-') -replace('é','-accentaigu-') -replace('è','-accentgrave-') -replace('&','-etcommercial-')) + + While ($AddBase -ne "") + { + $AddBase = Read-Host "Tapez le nom de la base (Laisser vide si toutes les bases ont été ajoutées) " + $Base = $Base + ($AddBase -replace(' ','-espace-') -replace('é','-accentaigu-') -replace('è','-accentgrave-') -replace('&','-etcommercial-')) + } + $BaseFormate = $Base -join "," + $BaseFormate = $BaseFormate.Substring(0,$BaseFormate.Length-1) + + Write-Host "" + Write-Host "`n $Instance $BaseFormate" + pause + } + if($choice -eq 16) + { + Write-Host -ForegroundColor Yellow "...::: UTM : Récupérer le port d'administration :::..." + $IPCheck = Read-Host "Indiquez l'adresse IP publique à vérifier " + + Write-Host "Test du port 443 : " + Test-NetConnection -ComputerName $IPCheck -Port 443 | Out-Null + if($Error.Count -eq 0) + { + Write-Host -ForegroundColor Green "OK !" + } + + Write-Host "Test du port 444 : " + Test-NetConnection -ComputerName $IPCheck -Port 444 | Out-Null + if($Error.Count -eq 0) + { + Write-Host -ForegroundColor Green "OK !" + } + + Write-Host "Test du port 4444 : " + Test-NetConnection -ComputerName $IPCheck -Port 4444 | Out-Null + if($Error.Count -eq 0) + { + Write-Host -ForegroundColor Green "OK !" + } + + Write-Host "Test du port 8443 : " + Test-NetConnection -ComputerName $IPCheck -Port 443 | Out-Null + if($Error.Count -eq 0) + { + Write-Host -ForegroundColor Green "OK !" + } + + Write-Host "Test du port 10443 : " + Test-NetConnection -ComputerName $IPCheck -Port 443 | Out-Null + if($Error.Count -eq 0) + { + Write-Host -ForegroundColor Green "OK !" + } + } + if($choice -eq 17) + { + + [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 + Invoke-WebRequest -Uri https://downloads.jam-software.de/treesize_free/TreeSizeFree-Portable.zip -outfile c:\alticap$\TreeSizeFree-Portable.zip + Expand-Archive -LiteralPath c:\alticap$\TreeSizeFree-Portable.zip -DestinationPath c:\alticap$\TreeSizeFree-Portable -Force + cd c:\alticap$\TreeSizeFree-Portable\ + .\TreeSizeFree.exe + + } + + if($choice -eq 18) + { + + [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 + Invoke-WebRequest -Uri https://alti365-my.sharepoint.com/personal/alexandre_mottier_alticap_com/_layouts/15/download.aspx?SourceUrl=/personal/alexandre_mottier_alticap_com/Documents/AdvancedIPScanner.zip -outfile c:\alticap$\AdvancedIPScanner.zip + Expand-Archive -LiteralPath c:\alticap$\AdvancedIPScanner.zip -DestinationPath c:\alticap$\AdvancedIPScanner + cd c:\alticap$\AdvancedIPScanner\ + .\advanced_ip_scanner.exe + } + + if($choice -eq "q") { + Write-Host "Fermeture..." + sleep 2 + break + } + +}