This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Compare-FolderSizeMethods | |
{ | |
[CmdletBinding()] | |
param ( | |
[Parameter(Mandatory)] | |
[string]$Path | |
) | |
$results = @{ | |
COM = 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param( | |
[Parameter(Mandatory = $false)] | |
[string]$SourcePath = "$env:windir\System32\winevt\Logs", | |
[Parameter(Mandatory = $false)] | |
[string]$DestinationPath = 'C:\temp2', | |
[Parameter(Mandatory = $false)] | |
[string]$FilePattern = '*.evtx', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
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 * |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Sync-FolderUsingRobocopy | |
{ | |
[CmdletBinding()] | |
param( | |
# Source Path | |
[Parameter(Mandatory = $true)] | |
[string]$Source, | |
# Destination Path | |
[Parameter(Mandatory = $true)] |
NewerOlder