Skip to content

Instantly share code, notes, and snippets.

View Rapidhands's full-sized avatar

Rapidhands

  • Ile-de-France, France
View GitHub Profile
@Rapidhands
Rapidhands / ExportComputers.ps1
Created July 30, 2025 00:56
Collecte des Compte machines dans l'AD avec IP et OS, et export dans un fichiers .xlsx
# Import du module Active Directory
Import-Module ActiveDirectory
# Collecte des info sur les ordinateurs dans Active Directory avec les propriétés souhaitées
$AllComputers = Get-ADComputer -Filter * -Property Name, OperatingSystem, IPv4Address
# initialisation d'une liste pour stocker les résultats
$results = [System.Collections.Generic.List[PSCustomObject]]::new()
# Boucle à travers les ordinateurs et création d'un objet personnalisé pour chaque ordinateur
@Rapidhands
Rapidhands / Check-NTFS.ps1
Last active April 7, 2025 12:32
How to chek NTFS permissions on subfolders. Example with large comments for explanation
<#
.SYNOPSIS
Analyzes NTFS permissions on folders and exports results to CSV or XLSX format.
.DESCRIPTION
This script recursively analyzes NTFS permissions on all subfolders of a specified path
and exports the results to either CSV or Excel format. It uses the NTFSSecurity module
for accurate permission analysis and ImportExcel for Excel export capabilities.
The name of the export file is NTFS_Permissions followed by the current date and time.
@Rapidhands
Rapidhands / Compare-FolderSizeMethods.ps1
Created January 16, 2025 10:26
Compare COM method and Powershell method (using Get-ChildItem) to get the size of a folder. COM method is incredibly faster
function Compare-FolderSizeMethods
{
[CmdletBinding()]
param (
[Parameter(Mandatory)]
[string]$Path
)
$results = @{
COM = 0
@Rapidhands
Rapidhands / Get-FolderSize..ps1
Created January 16, 2025 10:24
Get-FolderSize
function Get-FolderSize
{
<#
.SYNOPSIS
Calculates the size of a folder in the specified unit.
.DESCRIPTION
This function calculates the total size of a folder and its contents using the FileSystemObject COM object.
It supports various units of measurement (B, KB, MB, GB, TB) and allows customization of decimal places.
@Rapidhands
Rapidhands / ArchiveEventLogFiles.ps1
Last active January 25, 2025 21:29
Archive EventLog files
param(
[Parameter(Mandatory = $false)]
[string]$SourcePath = "$env:windir\System32\winevt\Logs",
[Parameter(Mandatory = $false)]
[string]$DestinationPath = 'C:\temp2',
[Parameter(Mandatory = $false)]
[string]$FilePattern = '*.evtx',
@Rapidhands
Rapidhands / gist:7855f8ddfee8c942fcdc95cc68bf7832
Created November 5, 2024 13:44
Create-SizedEmptyDummyFile
<#
.SYNOPSIS
Creates one or more empty dummy files of a specified size in a given directory.
.DESCRIPTION
The Create-SizedEmptyDummyFile function allows you to create one or more empty dummy files of a specified size in a given directory. It supports the creation of both regular files and sparse files, depending on the file size and the user's permissions.
.PARAMETER NumberOfFiles
The number of files to create.
@Rapidhands
Rapidhands / gist:a91fdc3fed37755aa406f722927e3cf5
Created October 23, 2024 06:33
Get Geolocation of the DNS Root servers
# DNS Root list
$rootServers = @(
"a.root-servers.net",
"b.root-servers.net",
"c.root-servers.net",
"d.root-servers.net",
"e.root-servers.net",
"f.root-servers.net",
"g.root-servers.net",
"h.root-servers.net",
@Rapidhands
Rapidhands / gist:3fab71fe3fe7c6b6af859e075483abbd
Created August 22, 2024 21:21
Gather Computer Real LastLogon
<#
At the 1st DC processed, we will have all the computers and their lastLogon in a ArrayList.
At the following DCs processed, only the LastLogon property of the computer being processed will be updated
#>
# Gathering DCs list
$DCList = Get-ADDomainController -Filter *
# Gathering Computer List
$AllComputers = Get-ADComputer -Filter *
function Measure-MyScript
{
<#
.SYNOPSIS
Measure speed execution of a scriptblock
.DESCRIPTION
Measure speed execution of a scriptblock, use it to optimze your code
.PARAMETER Name
@Rapidhands
Rapidhands / gist:7d6931fa9e972721922827aaa9596370
Created August 11, 2024 17:49
Sync folder functions using Robocopy
function Sync-FolderUsingRobocopy
{
[CmdletBinding()]
param(
# Source Path
[Parameter(Mandatory = $true)]
[string]$Source,
# Destination Path
[Parameter(Mandatory = $true)]