<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Need peice of Powershell code to convert bytes to highest unit in Software Development Kit (SDK) and API Discussions</title>
    <link>https://community.netapp.com/t5/Software-Development-Kit-SDK-and-API-Discussions/Need-peice-of-Powershell-code-to-convert-bytes-to-highest-unit/m-p/115614#M1759</link>
    <description>&lt;P&gt;Hi Andrew,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there any cmdlet to check volume and snapshot used capacity[the value return by "df -h" command's output("Capacity" field)] in percentage?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Charan&lt;/P&gt;</description>
    <pubDate>Wed, 10 Feb 2016 20:52:16 GMT</pubDate>
    <dc:creator>netappwala</dc:creator>
    <dc:date>2016-02-10T20:52:16Z</dc:date>
    <item>
      <title>Need peice of Powershell code to convert bytes to highest unit</title>
      <link>https://community.netapp.com/t5/Software-Development-Kit-SDK-and-API-Discussions/Need-peice-of-Powershell-code-to-convert-bytes-to-highest-unit/m-p/115600#M1757</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am writing a script for volume reporting. Can anyone tell me best way converting bytes to higest possible unit.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and is $vol.SnapshotBlocksReserved return size in blocks? do I have to divide this with 1024 to convert into bytes?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Charan&lt;/P&gt;</description>
      <pubDate>Wed, 04 Jun 2025 22:06:27 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Software-Development-Kit-SDK-and-API-Discussions/Need-peice-of-Powershell-code-to-convert-bytes-to-highest-unit/m-p/115600#M1757</guid>
      <dc:creator>netappwala</dc:creator>
      <dc:date>2025-06-04T22:06:27Z</dc:date>
    </item>
    <item>
      <title>Re: Need peice of Powershell code to convert bytes to highest unit</title>
      <link>https://community.netapp.com/t5/Software-Development-Kit-SDK-and-API-Discussions/Need-peice-of-Powershell-code-to-convert-bytes-to-highest-unit/m-p/115601#M1758</link>
      <description>&lt;P&gt;Use the "ConvertTo-FormattedNumber" cmdlet which ships with the NetApp PowerShell toolkit. &amp;nbsp;This will convert bytes to a human readable number...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;PS C:\&amp;gt; ConvertTo-FormattedNumber -Value 1024000 -Type DataSize -NumberFormatString 0
1000 KB

PS C:\&amp;gt; ConvertTo-FormattedNumber -Value 10240000 -Type DataSize -NumberFormatString 0
10 MB&lt;BR /&gt;&lt;BR /&gt;PS C:\&amp;gt; ConvertTo-FormattedNumber -Value 10240000 -Type DataSize -NumberFormatString 0.0&lt;BR /&gt;9.8 MB

PS C:\&amp;gt; ConvertTo-FormattedNumber -Value 102400000 -Type DataSize -NumberFormatString 0
98 MB&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Notice that it will round based on the "-NumberFormatString" value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If the result is in blocks, then each one represents 4096 bytes (4KB). &amp;nbsp;You'll need to multiply by 4096. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope that helps.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Andrew&lt;/P&gt;</description>
      <pubDate>Wed, 10 Feb 2016 15:42:05 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Software-Development-Kit-SDK-and-API-Discussions/Need-peice-of-Powershell-code-to-convert-bytes-to-highest-unit/m-p/115601#M1758</guid>
      <dc:creator>asulliva</dc:creator>
      <dc:date>2016-02-10T15:42:05Z</dc:date>
    </item>
    <item>
      <title>Re: Need peice of Powershell code to convert bytes to highest unit</title>
      <link>https://community.netapp.com/t5/Software-Development-Kit-SDK-and-API-Discussions/Need-peice-of-Powershell-code-to-convert-bytes-to-highest-unit/m-p/115614#M1759</link>
      <description>&lt;P&gt;Hi Andrew,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there any cmdlet to check volume and snapshot used capacity[the value return by "df -h" command's output("Capacity" field)] in percentage?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Charan&lt;/P&gt;</description>
      <pubDate>Wed, 10 Feb 2016 20:52:16 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Software-Development-Kit-SDK-and-API-Discussions/Need-peice-of-Powershell-code-to-convert-bytes-to-highest-unit/m-p/115614#M1759</guid>
      <dc:creator>netappwala</dc:creator>
      <dc:date>2016-02-10T20:52:16Z</dc:date>
    </item>
    <item>
      <title>Re: Need peice of Powershell code to convert bytes to highest unit</title>
      <link>https://community.netapp.com/t5/Software-Development-Kit-SDK-and-API-Discussions/Need-peice-of-Powershell-code-to-convert-bytes-to-highest-unit/m-p/115617#M1760</link>
      <description>&lt;P&gt;It's returned by Get-NcVol in the "VolumeSpaceAttributes" property...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Get-NcVol | Select Name,@{'N' = "PercentageSnapShotReserveUsed"; 'E' = { $_.VolumeSpaceAttributes.PercentageSnapshotReserveUsed }}&lt;/PRE&gt;&lt;P&gt;Andrew&lt;/P&gt;</description>
      <pubDate>Wed, 10 Feb 2016 21:33:32 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Software-Development-Kit-SDK-and-API-Discussions/Need-peice-of-Powershell-code-to-convert-bytes-to-highest-unit/m-p/115617#M1760</guid>
      <dc:creator>asulliva</dc:creator>
      <dc:date>2016-02-10T21:33:32Z</dc:date>
    </item>
    <item>
      <title>Re: Need peice of Powershell code to convert bytes to highest unit</title>
      <link>https://community.netapp.com/t5/Software-Development-Kit-SDK-and-API-Discussions/Need-peice-of-Powershell-code-to-convert-bytes-to-highest-unit/m-p/115651#M1763</link>
      <description>&lt;P&gt;I think DOT 7 Mode doesn't have that property &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Feb 2016 15:07:05 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Software-Development-Kit-SDK-and-API-Discussions/Need-peice-of-Powershell-code-to-convert-bytes-to-highest-unit/m-p/115651#M1763</guid>
      <dc:creator>netappwala</dc:creator>
      <dc:date>2016-02-11T15:07:05Z</dc:date>
    </item>
    <item>
      <title>Re: Need peice of Powershell code to convert bytes to highest unit</title>
      <link>https://community.netapp.com/t5/Software-Development-Kit-SDK-and-API-Discussions/Need-peice-of-Powershell-code-to-convert-bytes-to-highest-unit/m-p/115826#M1771</link>
      <description>&lt;P&gt;7-mode objects don't&amp;nbsp;directly return as much information, but we can still get the data by querying for the oldest snapshot and using it's cumulative total:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Get-NaVol | %{ 
    $data = "" | Select Filesystem,Total,Used,Avail,Capacity
    
    $snapReserve = $_.SnapshotBlocksReserved * 1024
    $snapUsed = ($_ | Get-NaSnapshot | Sort-Object -Property Created | Select-Object -First 1).CumulativeTotal

    $data.Filesystem = "/vol/$($_.Name)/.snapshot"
    $data.Total = ConvertTo-FormattedNumber $snapReserve DataSize
    $data.Used = ConvertTo-FormattedNumber $snapUsed DataSize
    $data.Avail = ConvertTo-FormattedNumber ($snapReserve - $snapUsed) DataSize
    $data.Capacity = ConvertTo-FormattedNumber (($snapUsed / $snapReserve) * 100) Percent

    $data
}&lt;/PRE&gt;&lt;P&gt;Andrew&lt;/P&gt;</description>
      <pubDate>Tue, 16 Feb 2016 15:08:29 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Software-Development-Kit-SDK-and-API-Discussions/Need-peice-of-Powershell-code-to-convert-bytes-to-highest-unit/m-p/115826#M1771</guid>
      <dc:creator>asulliva</dc:creator>
      <dc:date>2016-02-16T15:08:29Z</dc:date>
    </item>
    <item>
      <title>Re: Need peice of Powershell code to convert bytes to highest unit</title>
      <link>https://community.netapp.com/t5/Software-Development-Kit-SDK-and-API-Discussions/Need-peice-of-Powershell-code-to-convert-bytes-to-highest-unit/m-p/116093#M1797</link>
      <description>&lt;P&gt;Thats really useful Andrew. Below is what I found an alternative way.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;((get-naefficiency Vol0).snapusage).Reserve&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;((get-naefficiency Vol0).snapusage).used&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now need help to create an array of snapshots created dates for a volume.&amp;nbsp; I know Its more powershell related query than Data ONTAP.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Eg: If the Vol0 has 10 snapshots, I want to create a string array of size 10 that each eliment carries one snapshot's created date.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Kabir Charan&lt;/P&gt;</description>
      <pubDate>Sun, 21 Feb 2016 16:56:47 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Software-Development-Kit-SDK-and-API-Discussions/Need-peice-of-Powershell-code-to-convert-bytes-to-highest-unit/m-p/116093#M1797</guid>
      <dc:creator>netappwala</dc:creator>
      <dc:date>2016-02-21T16:56:47Z</dc:date>
    </item>
    <item>
      <title>Re: Need peice of Powershell code to convert bytes to highest unit</title>
      <link>https://community.netapp.com/t5/Software-Development-Kit-SDK-and-API-Discussions/Need-peice-of-Powershell-code-to-convert-bytes-to-highest-unit/m-p/116138#M1803</link>
      <description>&lt;P&gt;The DateTime object is somewhat more useful...you can do comparisons and intervals and such much easier...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;$snapTimes= (Get-NaSnapshot myvol).AccessTimeDT&lt;/PRE&gt;&lt;P&gt;Plus you can simply pipe to Out-String to get an actual string if needed...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;$snapTimes= (Get-NaSnapshot myvol).AccessTimeDT | Out-String&lt;/PRE&gt;&lt;P&gt;Hope that helps.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Andrew&lt;/P&gt;</description>
      <pubDate>Mon, 22 Feb 2016 16:36:34 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Software-Development-Kit-SDK-and-API-Discussions/Need-peice-of-Powershell-code-to-convert-bytes-to-highest-unit/m-p/116138#M1803</guid>
      <dc:creator>asulliva</dc:creator>
      <dc:date>2016-02-22T16:36:34Z</dc:date>
    </item>
  </channel>
</rss>

