Question Taille d'un dossier

Plus d'informations
il y a 11 ans 8 mois #4990 par ARRIVE
Réponse de ARRIVE sur le sujet Re:Taille d'un dossier
Bonjour Chris,

oui je serais intéressé par ce script tres interessant!! (Notamment pour la partie envoi d'un mail, et le reste aussi en fait :-))
Peut etre que tu peux le proposer pour qu'il soit intégré dans la bibliothèque des scripts??

@+

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 11 ans 8 mois #4992 par maycry
Réponse de maycry sur le sujet Re:Taille d'un dossier
je te le poste dés que possible<br><br>Message édité par: chris, à: 27/07/09 16:54

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 11 ans 8 mois #5000 par maycry
Réponse de maycry sur le sujet Re:Taille d'un dossier
Voici Mon script

3.bp.blogspot.com/_TbLKjL5jEmk/SnBI92w9O...XcLuE/s1600/Mail.png

[code:1]##################################################################################
# Version 2.0 : -- Stable
##################################################################################
# Check_Folders_Size.ps1
#************************************************************************






param( [string]$Server,[string]$RootFolder,[string]$Folder,[string]$smtp,[string]$from,[string]$to,[string]$subject,[switch]$help)


function GetHelp() {
$HelpText = @\&quot;

##################################################################################
# Version 2.0 : -- Stable
##################################################################################
# Check_Folders_Size.ps1
#************************************************************************
#
# Fonction :
#Script permettant d'obtenir la taille de chaque dossier et une addition afin d'en obtenir le total
#Ce script se base sur un chemin PArent identique pour chaque dossier.
#####################################################################################################################
Usage:
.\Get-FolderSize.ps1 -server \&quot;SERVERNAME\&quot; -folder c:\liste_des_Dossiers.log -smtp SMTPSERVER -subject \&quot;Checked_Folders_Lenght\&quot; -to Cette adresse e-mail est protégée contre les robots spammeurs. Vous devez activer le JavaScript pour la visualiser. -from Cette adresse e-mail est protégée contre les robots spammeurs. Vous devez activer le JavaScript pour la visualiser.

DESCRIPTION

NAME: Get-AD.ps1
Gets Information About Objects in Active-Directory

PARAMETERS:
-help show help
-Server Name of your Computer/Server for information in Reporting Mail
-Folder Path of your TextFile include list folders examine
-Smtp Name of your Server Smtp for send Mail
-Subject Name of Subject Mail
-To Name of your recipient Mailbox User or Distribution Group
-From Name of Sender

SYNTAX:

-folder

The folder parameter include a file containing the list of your folders should appear as follows:

D:\_WindowsServers_ISO
D:\Backup Windows Server 2008 WSSM
D:\EASEUS.Partition.Manager.v3.0.1.Ultimate.Edition-FOSI
D:\Kapersky_PlateForme2009
D:\Quest SoftWare
D:\WSSM_V0.4
D:\XP SP3 XI386
C:\_Admin_Tools

\&quot;@
$HelpText
}

if ($help) {
GetHelp
Continue
}



#*******************************************************************************************#
# *Creation d'un tableau entier contenant la liste des noms des dossiers #
$TABLE_NAME = @() #
# #
# *Incrémentation de la taille du dossier afin d'en résulter un calcul total du cumul #
$TABLE_SIZE = @() #
#*******************************************************************************************#


if ($Folder -eq \&quot;\&quot;«»)
{
Write-warning \&quot;No list Folders specified\&quot;
GetHelp
}
else
{
if ((Test-Path $Folder) -eq $false)
{
Write-warning \&quot;Not Path found for $Folder\&quot;
Write-Warning \&quot;You must Specify Path to Folder ==&gt; Exemple'c:\test'\&quot;

}
else
{
Write-Host \&quot;Using Folders list: $Folder\&quot;
$ReadFolders = Get-Content $Folder
Foreach ($Add_Value in $ReadFolders)
{
$TABLE_NAME += $Add_Value
}

# =====================================================================================================================
# START HTML FILE FOR MAIL REPORTING
# =====================================================================================================================


$Date = Get-Date
$HTML_File = \&quot;$env:«»systemdrive\\&quot; + $server + \&quot;_\&quot; + $date.Hour + $date.Minute + \&quot;_\&quot; + $Date.Day + \&quot;-\&quot; + $Date.Month + \&quot;-\&quot; + $Date.Year + \&quot;.htm\&quot;

# =====================================================================================================================
# CREATE HTML OUTPUT
# =====================================================================================================================

Write-Output \&quot; \&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output '&lt;!DOCTYPE HTML PUBLIC \&quot;-//W3C//DTD HTML 4.0 Transitional//EN\&quot;&gt;'| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output '&lt;html ES_auditInitialized='false'&gt;&lt;head&gt;&lt;title&gt;Audit&lt;/title&gt;'| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot;&lt;META http-equiv=Content-Type content='text/html; charset=windows-1252'&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File

##########################################Start of Style Definition Section ##########################################

Write-Output \&quot;&lt;STYLE type=text/css&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File

Write-Output \&quot; DIV .expando {DISPLAY: block; FONT-WEIGHT: normal; FONT-SIZE: 8pt; RIGHT: 10px; COLOR: #0D1B21; FONT-FAMILY: Tahoma; POSITION: absolute; TEXT-DECORATION: underline}\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; TABLE {TABLE-LAYOUT: fixed; FONT-SIZE: 100%; WIDTH: 100%}\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; .heading0_expanded {BORDER-RIGHT: #bbbbbb 1px solid; PADDING-RIGHT: 5em; BORDER-TOP: #bbbbbb 1px solid; DISPLAY: block; PADDING-LEFT: 8px; FONT-WEIGHT: bold; FONT-SIZE: 13pt; MARGIN-BOTTOM: -1px; MARGIN-LEFT: 0px; BORDER-LEFT: #bbbbbb 1px solid; WIDTH: 100%; CURSOR: hand; COLOR: #0D1B21; MARGIN-RIGHT: 0px; PADDING-TOP: 4px; BORDER-BOTTOM: #bbbbbb 1px solid; FONT-FAMILY: Tahoma; POSITION: relative; HEIGHT: 2.25em; BACKGROUND-COLOR: #C22523}\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; .heading1 {BORDER-RIGHT: #bbbbbb 1px solid; PADDING-RIGHT: 5em; BORDER-TOP: #bbbbbb 1px solid; DISPLAY: block; PADDING-LEFT: 16px; FONT-WEIGHT: bold; FONT-SIZE: 11pt; MARGIN-BOTTOM: -1px; MARGIN-LEFT: 5px; BORDER-LEFT: #bbbbbb 1px solid; WIDTH: 100%; CURSOR: hand; COLOR: #0D1B21; MARGIN-RIGHT: 0px; PADDING-TOP: 4px; BORDER-BOTTOM: #bbbbbb 1px solid; FONT-FAMILY: Arial Black; POSITION: relative; HEIGHT: 2.25em; BACKGROUND-COLOR: #F0E68C}\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; .heading2 {BORDER-RIGHT: #bbbbbb 1px solid; PADDING-RIGHT: 5em; BORDER-TOP: #bbbbbb 1px solid; DISPLAY: block; PADDING-LEFT: 16px; FONT-WEIGHT: bold; FONT-SIZE: 11pt; MARGIN-BOTTOM: -1px; MARGIN-LEFT: 5px; BORDER-LEFT: #bbbbbb 1px solid; WIDTH: 100%; CURSOR: hand; COLOR: #0D1B21; MARGIN-RIGHT: 0px; PADDING-TOP: 4px; BORDER-BOTTOM: #bbbbbb 1px solid; FONT-FAMILY: Tahoma; POSITION: relative; HEIGHT: 2.25em; BACKGROUND-COLOR:green}\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File

Write-Output \&quot; .tableDetail {BORDER-RIGHT: #bbbbbb 1px solid; BORDER-TOP: #bbbbbb 1px solid; DISPLAY: block; PADDING-LEFT: 16px; FONT-SIZE: 10pt;MARGIN-BOTTOM: -1px; PADDING-BOTTOM: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #bbbbbb 1px solid; WIDTH: 100%; COLOR: #000000; MARGIN-RIGHT: 0px; PADDING-TOP: 4px; BORDER-BOTTOM: #bbbbbb 1px solid; FONT-FAMILY: Tahoma; POSITION: relative; BACKGROUND-COLOR:«»silver}\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; .tableDetail2 {BORDER-RIGHT: #bbbbbb 1px solid; BORDER-TOP: #bbbbbb 1px solid; DISPLAY: block; PADDING-LEFT: 16px; FONT-SIZE: 10pt;MARGIN-BOTTOM: -1px; PADDING-BOTTOM: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #bbbbbb 1px solid; WIDTH: 100%; COLOR: #000000; MARGIN-RIGHT: 0px; PADDING-TOP: 4px; BORDER-BOTTOM: #bbbbbb 1px solid; FONT-FAMILY: Tahoma; POSITION: relative; BACKGROUND-COLOR: #FFFFCC}\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; .filler {BORDER-RIGHT: medium none; BORDER-TOP: medium none; DISPLAY: block; BACKGROUND: none transparent scroll repeat 0% 0%; MARGIN-BOTTOM: -1px; FONT: 100%/8px Tahoma; MARGIN-LEFT: 43px; BORDER-LEFT: medium none; COLOR: #0D1B21; MARGIN-RIGHT: 0px; PADDING-TOP: 4px; BORDER-BOTTOM: medium none; POSITION: relative}\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; .Solidfiller {BORDER-RIGHT: medium none; BORDER-TOP: medium none; DISPLAY: block; BACKGROUND: none transparent scroll repeat 0% 0%; MARGIN-BOTTOM: -1px; FONT: 100%/8px Tahoma; MARGIN-LEFT: 0px; BORDER-LEFT: medium none; COLOR: #000000; MARGIN-RIGHT: 0px; PADDING-TOP: 4px; BORDER-BOTTOM: medium none; POSITION: relative; BACKGROUND-COLOR: #000000}\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; td {VERTICAL-ALIGN: TOP; FONT-FAMILY: Tahoma}\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; th {VERTICAL-ALIGN: TOP; COLOR: #cc0000; TEXT-ALIGN: left}\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File

Write-Output \&quot;&lt;/STYLE&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File

#
End of Style Definition Section

########################################## Start of BODY HEAD Section HTML Code ##########################################

Write-Output \&quot;&lt;BODY&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output ' &lt;p&gt;&lt;b&gt;&lt;font face=\&quot;Arial\&quot; size=\&quot;5\&quot;&gt;'$server' Status Size (Folder(s) &amp; Disks)&lt;hr size=\&quot;8\&quot; color=\&quot;#CC0000\&quot;&gt;&lt;/font&gt;&lt;/b&gt;'| out-file -Append -encoding ASCII -filepath $HTML_File

Write-Output ' &lt;font face=\&quot;Arial\&quot; size=\&quot;1\&quot;&gt;Report generated on ' (Get-Date) '&lt;/font&gt;&lt;/p&gt;'| out-file -Append -encoding ASCII -filepath $HTML_File

Write-Output \&quot;&lt;TABLE cellSpacing=0 cellPadding=0&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;TBODY&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;TR&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;TD&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;DIV id=objshowhide tabIndex=0&gt;&lt;FONT face=Arial&gt;&lt;/FONT&gt;&lt;/DIV&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;/TD&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;/TR&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;/TBODY&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot;&lt;/TABLE&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File

#================= End of BODY HEAD Section HTML Code #=================


##########################################Start of COMPUTER DETAILS Section HTML Code ##########################################

Write-Output \&quot;&lt;DIV class=heading0_expanded&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;SPAN class=sectionTitle tabIndex=0&gt;$server Details&lt;/SPAN&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;A class=expando href='#'&gt;&lt;/A&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot;&lt;/DIV&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot;&lt;DIV class=filler&gt;&lt;/DIV&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
#================= End of Server Detail SEction HTML Code #=================

##########################################Start of FOLDERS SIZE DETAILS -Sub-section HTML Code ##########################################

write-output \&quot;Ecriture en cours pour la categorie FOLDERS SIZE DETAIL\&quot;



Write-Output \&quot; &lt;DIV class=container&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;DIV class=heading1&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;SPAN class=sectionTitle tabIndex=0&gt;GLOBAL STATUS DISK&lt;/SPAN&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;A class=expando href='#'&gt;&lt;/A&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;/DIV&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;DIV class=container&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;DIV class=tableDetail&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;TABLE&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;tr&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;th width='30%'&gt;&lt;b&gt;Nom du dossier&lt;/b&gt;&lt;/font&gt;&lt;/th&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;th width='20%'&gt;&lt;b&gt;Taille en MB&lt;/b&gt;&lt;/font&gt;&lt;/th&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;th width='20%'&gt;&lt;b&gt;Taille en GB&lt;/b&gt;&lt;/font&gt;&lt;/th&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;th width='15%'&gt;&lt;b&gt;TOTAL en MB&lt;/b&gt;&lt;/font&gt;&lt;/th&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;th width='15%'&gt;&lt;b&gt;TOTAL en GB&lt;/b&gt;&lt;/font&gt;&lt;/th&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File

Write-Output \&quot; &lt;/tr&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;tr&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;td width='30%'&gt;\&quot;
\&quot;&lt;/font&gt;&lt;/td&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;td width='20%'&gt;\&quot;
\&quot;&lt;/font&gt;&lt;/td&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;td width='20%'&gt;\&quot;
\&quot;&lt;/font&gt;&lt;/td&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;td width='15%'&gt;\&quot;
\&quot;&lt;/font&gt;&lt;/td&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;td width='15%'&gt;\&quot;
\&quot;&lt;/font&gt;&lt;/td&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;/tr&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File



for($n=0; $n -lt ($TABLE_NAME).count; $n++)
{
$PathName = $TABLE_NAME[$n]
Write-Host \&quot;Calcul du dossier dont Le chemin d'acces est $PathName\&quot;
#################################################################################
#
$Object_FileSystem = New-Object -com Scripting.FileSystemObject
$Size_Path = ($Object_FileSystem.getfolder($PathName)).size
$FolderName = ($Object_FileSystem.getfolder($PathName)).name
Write-Host \&quot;Le nom du dossier est $FolderName\&quot;
$GetSize_MB = ([math]::round($Size_Path/1MB,2))
Write-Host \&quot;Le nom du dossier est $GetSize_MB MB\&quot;
$GetSize_GB = ([math]::round($Size_Path/1GB,1))
Write-Host \&quot;Le nom du dossier est $GetSize_GB GB\&quot;
#==============================|
$TotalFolder_MB += $GetSize_MB#|
$TotalFolder_GB += $GetSize_GB#|
#==============================|
#
#################################################################################


Write-Output \&quot; &lt;tr&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;td width='15%'&gt;\&quot;'|'$FolderName\&quot;&lt;/font&gt;&lt;/td&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;td width='20%'&gt;\&quot;'|'$GetSize_MB MB\&quot;&lt;/font&gt;&lt;/td&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;td width='20%'&gt;\&quot;'|'$GetSize_GB GB\&quot;&lt;/font&gt;&lt;/td&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
}


Write-Output \&quot; &lt;/tr&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File

#$TotalFolder = 0
#$InitTable = $TABLE_SIZE

#for ($i = 0; $i -lt ($TABLE_SIZE).count; $i += 1)
# {
# $TotalFolder += $InitTable[$i]
# }
Write-Output \&quot; &lt;tr&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;/td&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;td width='45'&gt;\&quot;'|'$TotalFolder_MB MB\&quot;&lt;/font&gt;&lt;/td&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;td width='45'&gt;\&quot;'|'$TotalFolder_GB GB\&quot;&lt;/font&gt;&lt;/td&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;/tr&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File

Write-Output \&quot; &lt;/TABLE&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;/DIV&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;/DIV&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;/DIV&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;DIV class=filler&gt;&lt;/DIV&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File


#
End of FOLDERS SIZE DETAILS -Sub-section HTML Code #=================

########################################## Start of COMPUTER DETAILS - LOGICAL DISK CONFIGURATION Sub-section HTML Code ##########################################

write-output \&quot;Ecriture en cours pour la categorie Logical Disks\&quot;

$DiscoverDisk = Get-WmiObject -ComputerName $server Win32_LogicalDisk

Write-Output \&quot; &lt;DIV class=container&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;DIV class=heading1&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;SPAN class=sectionTitle tabIndex=0&gt;Logical Disk Configuration&lt;/SPAN&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;A class=expando href='#'&gt;&lt;/A&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;/DIV&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;DIV class=container&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;DIV class=tableDetail&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;TABLE&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;tr&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;th width='15%'&gt;&lt;b&gt;Drive Letter&lt;/b&gt;&lt;/font&gt;&lt;/th&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;th width='20%'&gt;&lt;b&gt;Label&lt;/b&gt;&lt;/font&gt;&lt;/th&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;th width='20%'&gt;&lt;b&gt;File System&lt;/b&gt;&lt;/font&gt;&lt;/th&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;th width='15%'&gt;&lt;b&gt;Disk Size&lt;/b&gt;&lt;/font&gt;&lt;/th&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;th width='15%'&gt;&lt;b&gt;Disk Free Space&lt;/b&gt;&lt;/font&gt;&lt;/th&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;th width='15%'&gt;&lt;b&gt;% Free Space&lt;/b&gt;&lt;/font&gt;&lt;/th&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;/tr&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File


Write-Output \&quot; &lt;tr&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;td width='15%'&gt;\&quot;
\&quot;&lt;/font&gt;&lt;/td&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;td width='20%'&gt;\&quot;
\&quot;&lt;/font&gt;&lt;/td&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;td width='20%'&gt;\&quot;
\&quot;&lt;/font&gt;&lt;/td&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;td width='15%'&gt;\&quot;
\&quot;&lt;/font&gt;&lt;/td&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;td width='15%'&gt;\&quot;
\&quot;&lt;/font&gt;&lt;/td&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;td width='15%'&gt;\&quot;
\&quot;&lt;/font&gt;&lt;/td&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;/tr&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File

Foreach ($objDisk in $DiscoverDisk)
{
if ($objDisk.DriveType -eq 3)
{
Write-Output \&quot; &lt;tr&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;td width='15%'&gt;\&quot;'|'$objDisk.DeviceID\&quot;&lt;/font&gt;&lt;/td&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;td width='20%'&gt;\&quot;'|'$objDisk.VolumeName\&quot;&lt;/font&gt;&lt;/td&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;td width='20%'&gt;\&quot;'|'$objDisk.FileSystem\&quot;&lt;/font&gt;&lt;/td&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
#$F_GB = [math]::round($Freespace/1GB,1)
#$Used = [math]::round(([int64]$Size-[int64]$Freespace))
$disksize0= $objDisk.Size
$disksize = [math]::round($disksize0/1GB,1)
Write-Output \&quot; &lt;td width='15%'&gt;\&quot;'|'$disksize\&quot; GB&lt;/font&gt;&lt;/td&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File

$Freespace0= $objDisk.FreeSpace
$freespace = [math]::round($Freespace0 /1GB,1)
Write-Output \&quot; &lt;td width='15%'&gt;\&quot;'|'$Freespace\&quot; GB&lt;/font&gt;&lt;/td&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File

$percFreespace=[math]::round(((($objDisk.FreeSpace /1048576)/($objDisk.Size / 1048676)) * 100),0)
Write-Output \&quot; &lt;td width='15%'&gt;\&quot;'|'$percFreespace\&quot; %&lt;/font&gt;&lt;/td&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;/tr&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
}
}

Write-Output \&quot; &lt;/TABLE&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;/DIV&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;/DIV&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;/DIV&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File
Write-Output \&quot; &lt;DIV class=filler&gt;&lt;/DIV&gt;\&quot;| out-file -Append -encoding ASCII -filepath $HTML_File

#================= End of COMPUTER DETAILS - LOGICAL DISK CONFIGURATION Sub-section HTML Code #=================




#send mail function
Function Send-Email {
Param([string]$smtp,
[string]$To,
[string]$From,
[string]$subject,
[string]$body,
[string]$file,
[string]$username,
[string]$password
)
#Create SMTP Client object
$mail = New-Object system.net.mail.smtpclient($smtp)

#if credentials specifiec create NetworkCredential object
if ($username -and $password) {
$mailcred=New-Object system.net.NetworkCredential ($username,$password)
$mail.credentials=$mailcred
}

$msg = New-Object system.Net.Mail.MailMessage ($From,$To,$subject,$body)
$msg.IsBodyHTML = $true
#if file attachment specified, add it to the message
if ($file) {
$attach=New-Object system.Net.Mail.Attachment $file
$msg.Attachments.add($attach)
}

#send message
$mail.send($msg)

}

#validate other mail parameters
if (! $SendTo -or ! $From) {
Write-Warning \&quot;You forgot to specify either -SendTo and/or -From\&quot;
}
else {
Write-Debug \&quot;Sending mail to $SendTo\&quot;
$body=\&quot;See the attached report for recent error events.\&quot;
Send-Email -smtp $smtp -Sendto $To -from $From `
-subject $subject -body $body -username $username `
-password $password -file $HTML_File

Write-Host \&quot;Sending mail to $SendTo\&quot; -foregroundcolor Green
}

write-host \&quot;Subject Mail: $subject\&quot;
write-host \&quot;From Mail: $from\&quot;
write-host \&quot;To Mail: $to\&quot;
write-host \&quot;Smtp Server Mail: $smtp\&quot;

$ReadHTML = Get-Content $HTML_File
(Send-EMail -subject $subject -from $from -to $to -smtp $smtp -body $ReadHTML).waitforexit
Remove-Item $HTML_File -Confirm:$false

}
}


[/code:1]

La pièce jointe Get_FolderSize.ps1 est absente ou indisponible

<br><br>Message édité par: chris, à: 29/07/09 15:52
Pièces jointes :

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 10 ans 9 mois #7285 par zoran lukenic
Réponse de zoran lukenic sur le sujet Re:Taille d'un dossier
Salut chris. Ton script est excellent. C'est éxactement ce que je cherchai. Par contre je rencontre un petit soucis.
J'execute le script sur ma machine ( Win XP SP3 ) pour scanner les dossiers partagés de mon serveur ( Win2003 R2 sp2 ). Le rapport HTML se fait correctement sauf que sur certains partages, malgré le temps d'analyse, la valeur remontée est 0. Je n'ai pas trouvé ce qui peux provoquer ça. En attendant de trouver je voulai savoir si tu as rencontré ce soucis et si oui comment l'a tu résolu.
Pour info, je n'ai pas ce soucis avec d'autres outils comme JDiskReport.

Connexion ou Créer un compte pour participer à la conversation.

Temps de génération de la page : 0.128 secondes
Propulsé par Kunena