<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Folder size via agent]]></title><description><![CDATA[<p dir="auto">Hi.<br />
How i can get a folder size on remote host via agent or script?<br />
Thanks.</p>
]]></description><link>https://forum.netxms.org/topic/2289/folder-size-via-agent</link><generator>RSS for Node</generator><lastBuildDate>Fri, 13 Nov 2026 12:22:36 GMT</lastBuildDate><atom:link href="https://forum.netxms.org/topic/2289.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 09 Apr 2013 10:22:25 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Folder size via agent on Tue, 16 Apr 2013 06:10:28 GMT]]></title><description><![CDATA[<p dir="auto">Hi!</p>
<p dir="auto">You can also use File.Size parameter:</p>
<p dir="auto">File.Size(directory,*,1)</p>
<p dir="auto">this will get size of all files in given directory and subdirectories. If you want to ignore subdirectories, you can use form</p>
<p dir="auto">File.Size(directory,*,0)</p>
<p dir="auto">Full description of File.Size and File.Count arguments:</p>
<p dir="auto">File.Size and File.Count accepts the following arguments:<br />
    path, pattern, recursive, size, age<br />
where<br />
    path    : path to directory or file to check<br />
    pattern : pattern for file name matching<br />
    recursive : recursion flag; if set to 1 or true, agent will scan subdirectories<br />
    size      : size filter; if &lt; 0, only files with size less than abs(value) will match;<br />
                if &gt; 0, only files with size greater than value will match<br />
    age       : age filter; if &lt; 0, only files created after now - abs(value) will match;<br />
                if &gt; 0, only files created before now - value will match</p>
<p dir="auto">All arguments except first can be omitted.</p>
<p dir="auto">Best regards,<br />
Victor</p>
]]></description><link>https://forum.netxms.org/post/10092</link><guid isPermaLink="true">https://forum.netxms.org/post/10092</guid><dc:creator><![CDATA[victor]]></dc:creator><pubDate>Tue, 16 Apr 2013 06:10:28 GMT</pubDate></item><item><title><![CDATA[Reply to Folder size via agent on Tue, 09 Apr 2013 14:18:27 GMT]]></title><description><![CDATA[<p dir="auto">Just some notes:</p>
<ol>
<li>I'd add error handling, like this:</li>
</ol>
<pre><code>Try {
	"{0:F2}" -f ((Get-ChildItem $args[0] -r -ErrorAction stop | Measure-Object -property length -sum).sum / 1KB)
}
Catch {
	Write-Host "0.00"
}
</code></pre>
<ol start="2">
<li>If you plan to scan large directories and it could potentially take long time, it's better to use <a href="http://wiki.netxms.org/wiki/ExternalParametersProvider" rel="nofollow ugc">ExternalParametersProvider</a> with script like this:</li>
</ol>
<pre><code>$dirs = @("c:\DosBox", "C:\tmp")

foreach ($dir in $dirs) {
	$size = "0.00"
	Try {
		$size="{0:F2}" -f ((Get-ChildItem $dir -r -ErrorAction stop | Measure-Object -property length -sum).sum / 1KB)
	}
	Catch {
	}
	Write-Host "DirSize($dir)=$size"
}
</code></pre>
<ol start="3">
<li>If these script saved as a file, PowerShell may require to sign it before running, disable execution policy:</li>
</ol>
<pre><code>powershell -ExecutionPolicy ByPass -File ...\script.ps1
</code></pre>
]]></description><link>https://forum.netxms.org/post/10061</link><guid isPermaLink="true">https://forum.netxms.org/post/10061</guid><dc:creator><![CDATA[alk]]></dc:creator><pubDate>Tue, 09 Apr 2013 14:18:27 GMT</pubDate></item><item><title><![CDATA[Reply to Folder size via agent on Tue, 09 Apr 2013 13:43:13 GMT]]></title><description><![CDATA[<p dir="auto">Maybe to someone it helps...get folder size in windows with powershell</p>
<p dir="auto">1.Edit <strong>nxagentd.conf</strong> and paste next<br />
<strong>ExternalParameter = FolderSize(*):powershell.exe ( Get-ChildItem $1 -Recurse -Force | Measure-Object -Property Length -Sum ).Sum / 1KB</strong> or /1MB if you want Mbytes, /1GB etc....<br />
2.Restart agent.<br />
3.Add Parameter to your node.<br />
Enjoy.  <img src="https://forum.netxms.org/assets/plugins/nodebb-plugin-emoji/emoji/android/1f642.png?v=72b86a538fc" class="not-responsive emoji emoji-android emoji--slightly_smiling_face" style="height:1.4em;width:auto;vertical-align:middle" title=":)" alt="🙂" /></p>
]]></description><link>https://forum.netxms.org/post/10060</link><guid isPermaLink="true">https://forum.netxms.org/post/10060</guid><dc:creator><![CDATA[berlin15]]></dc:creator><pubDate>Tue, 09 Apr 2013 13:43:13 GMT</pubDate></item></channel></rss>