2023-02-18 16:26:02 +01:00
##[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 "
2023-02-18 17:07:11 +01:00
Write-Host " 2. Lister les mots de passe Active Directory expirés "
Write-Host " 3. Générateur de mots de passe "
2023-02-18 16:26:02 +01:00
Write-Host " "
Write-Host -ForegroundColor Yellow " ..:: Serveurs ::.. "
Write-Host " "
2023-02-18 17:07:11 +01:00
Write-Host " 4. Lister les utilisateurs d'un broker RDS "
2023-02-18 17:11:37 +01:00
Write-Host " 5. Mettre le serveur à l'heure via fr.pool.ntp.org "
2023-02-18 17:07:11 +01:00
Write-Host " 6. Programmer un redémarrage "
Write-Host " 7. Programmer un arrêt "
Write-Host " 8. Lister les contrôleurs de domaine d'un serveur "
2023-02-18 16:26:02 +01:00
Write-Host " "
Write-Host -ForegroundColor Yellow " ..:: Autres outils ::.. "
Write-Host " "
2023-02-18 17:07:11 +01:00
Write-Host " 9. Récupérer des informations sur la passerelle réseau et le FAI "
Write-Host " 10. Nettoyer les caches des navigateurs (Chrome, Firefox, IE, Edge) "
Write-Host " 11. Lister les serveurs de messagerie d'un domaine "
Write-Host " 12. Purger les téléchargements de tous les utilisateurs sur une machine "
Write-Host " 13. Lancer TreeSizeFree (téléchargement de la dernière version) "
2023-02-18 16:26:02 +01:00
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. "
}
}
}
2023-02-18 17:07:11 +01:00
if ( $choice -eq 2 )
2023-02-18 16:26:02 +01:00
{
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
}
2023-02-18 17:07:11 +01:00
if ( $choice -eq 3 )
2023-02-18 16:26:02 +01:00
{
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. "
}
}
2023-02-18 17:07:11 +01:00
if ( $choice -eq 4 )
2023-02-18 16:26:02 +01:00
{
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
}
2023-02-18 17:07:11 +01:00
if ( $choice -eq 5 )
2023-02-18 16:26:02 +01:00
{
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
}
2023-02-18 17:07:11 +01:00
if ( $choice -eq 6 )
2023-02-18 16:26:02 +01:00
{
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
}
2023-02-18 17:07:11 +01:00
if ( $choice -eq 7 )
2023-02-18 16:26:02 +01:00
{
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
}
2023-02-18 17:07:11 +01:00
if ( $choice -eq 8 )
2023-02-18 16:26:02 +01:00
{
2023-02-18 17:07:11 +01:00
Write-Host -ForegroundColor Yellow " ...::: Contrôleur(s) de domaine de cette machine :::... "
2023-02-18 16:26:02 +01:00
Write-Host " "
$DomainControllers = ( ( Get-ADForest ) . GlobalCatalogs )
echo $DomainControllers
sleep 10
}
2023-02-18 17:07:11 +01:00
if ( $choice -eq 9 )
2023-02-18 16:26:02 +01:00
{
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 ). `n Local IP is $AdresseIP . `n Public IP is $PublicIP . "
}
else
{
Write-Host " Gateway vendor is $Router ( $GatewayMac ). `n Local IP is $AdresseIP . `n Public IP is $PublicIP ( $ISP ). "
}
sleep 10
}
2023-02-18 17:07:11 +01:00
if ( $choice -eq 10 )
2023-02-18 16:26:02 +01:00
{
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
}
2023-02-18 17:07:11 +01:00
if ( $choice -eq 11 )
2023-02-18 16:26:02 +01:00
{
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
}
}
2023-02-18 17:07:11 +01:00
if ( $choice -eq 12 )
2023-02-18 16:26:02 +01:00
{
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
}
2023-02-18 17:07:11 +01:00
if ( $choice -eq 13 )
2023-02-18 16:26:02 +01:00
{
2023-02-18 17:07:11 +01:00
Write-Host -ForegroundColor Yellow " ...::: Télécharger et lancer TreeSizeFree :::... "
Write-Host " "
2023-02-18 16:26:02 +01:00
[ Net.ServicePointManager ] :: SecurityProtocol = [ Net.SecurityProtocolType ] :: Tls12
2023-02-18 17:07:11 +01:00
Invoke-WebRequest -Uri https : / / downloads . jam-software . de / treesize_free / TreeSizeFree-Portable . zip -outfile c: \ TreeSizeFree-Portable . zip
Expand-Archive -LiteralPath c: \ TreeSizeFree-Portable . zip -DestinationPath c: \ TreeSizeFree-Portable -Force
cd c: \ TreeSizeFree-Portable \
2023-02-18 16:26:02 +01:00
. \ TreeSizeFree . exe
}
if ( $choice -eq " q " ) {
Write-Host " Fermeture... "
sleep 2
break
}
}