<?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: How to combine Get-NcSnapshot &amp;amp; Get-NcAggr in a Powershell script in ONTAP Discussions</title>
    <link>https://community.netapp.com/t5/ONTAP-Discussions/How-to-combine-Get-NcSnapshot-amp-Get-NcAggr-in-a-Powershell-script/m-p/150628#M33524</link>
    <description>&lt;P&gt;Hi Donny,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You are absolutely star. Didn't have to edit anything, just copy pasted and it worked like a charm.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Wow..that's a beauty of community support, I don't have to break my head for something for which there are experts available already.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just being a little more greedy, just a query : I can easily take this aggr name and check it's used %&amp;nbsp; But, I was wondering if I can feed in - Get-NcAggr and pull in $_.Aggregate from the Get-NcVol ouput and calcualte the % used, total , availabe in the same excel. I want to know how to insert another Get-NcAggr in that script.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Many thanks again.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You rock.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;-Ash&lt;/P&gt;</description>
    <pubDate>Fri, 30 Aug 2019 15:43:44 GMT</pubDate>
    <dc:creator>Ontapforrum</dc:creator>
    <dc:date>2019-08-30T15:43:44Z</dc:date>
    <item>
      <title>How to combine Get-NcSnapshot &amp; Get-NcAggr in a Powershell script</title>
      <link>https://community.netapp.com/t5/ONTAP-Discussions/How-to-combine-Get-NcSnapshot-amp-Get-NcAggr-in-a-Powershell-script/m-p/150534#M33490</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to create a simple powershell script to generate snaps older than x days, that bit is easy.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, Get-NcSnapshot does not yeild 'Aggr' Name, so I have added :&lt;/P&gt;
&lt;P&gt;Get-NcAggr | where { $_.Volume -eq $x.Volume }&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Objective: Getting snapshots older than x days is a bit and it gives information about which volume and vserver it belongs to along with the size of the snap, but it does not tell you which aggregate the snapshot-volume belongs to. Especially in a thin environment, where you can give back space to aggr by removing the snapshot.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Finally outputing it to CSV, problem is : Both Get-NcSnapshot &amp;amp; Get-NaAggr has common 'Name' column, hence it ignores the Aggr name, and simply populates the Agg 'Name' column with 'volumename'.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there a way to combine both these commands despite having same column name 'Name'?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;BR /&gt;-Ashwin&lt;/P&gt;</description>
      <pubDate>Wed, 04 Jun 2025 12:17:25 GMT</pubDate>
      <guid>https://community.netapp.com/t5/ONTAP-Discussions/How-to-combine-Get-NcSnapshot-amp-Get-NcAggr-in-a-Powershell-script/m-p/150534#M33490</guid>
      <dc:creator>Ontapforrum</dc:creator>
      <dc:date>2025-06-04T12:17:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine Get-NcSnapshot &amp; Get-NcAggr in a Powershell script</title>
      <link>https://community.netapp.com/t5/ONTAP-Discussions/How-to-combine-Get-NcSnapshot-amp-Get-NcAggr-in-a-Powershell-script/m-p/150587#M33509</link>
      <description>&lt;P&gt;you can add the data to a new column using add-member&lt;/P&gt;
&lt;PRE class="lang-bsh prettyprint prettyprinted"&gt;&lt;CODE&gt;&lt;SPAN class="str"&gt;$snaps = get-ncsnapsot | %{$_ | Add-Member -type NoteProperty -name AggrName -Value ($_ | get-ncvol).Aggregate}&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;* i didn't tested it as i don't have the simulator running now... &lt;/P&gt;
&lt;P&gt;Gidi&lt;/P&gt;</description>
      <pubDate>Thu, 29 Aug 2019 16:14:01 GMT</pubDate>
      <guid>https://community.netapp.com/t5/ONTAP-Discussions/How-to-combine-Get-NcSnapshot-amp-Get-NcAggr-in-a-Powershell-script/m-p/150587#M33509</guid>
      <dc:creator>GidonMarcus</dc:creator>
      <dc:date>2019-08-29T16:14:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine Get-NcSnapshot &amp; Get-NcAggr in a Powershell script</title>
      <link>https://community.netapp.com/t5/ONTAP-Discussions/How-to-combine-Get-NcSnapshot-amp-Get-NcAggr-in-a-Powershell-script/m-p/150598#M33516</link>
      <description>&lt;P&gt;&lt;a href="https://community.netapp.com/t5/user/viewprofilepage/user-id/38137"&gt;@GidonMarcus&lt;/a&gt;&amp;nbsp;I get an "get-ncvol : Unable to find API: volume-get-iter on node vserver lab-clst-01-n1" error when attempting to run your code (ONTAP 9.6 and PS Toolkit 9.6).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use Select-Object to add a calculated property to your output though like this (will get all snapshots older than 90 days)&lt;/P&gt;
&lt;PRE&gt;$90days = (get-date).adddays(-90)
Get-NcSnapshot | Where-Object { ($_.Created -lt "$90days") } | Select-Object Name, Vserver, Created, Total, @{l="Aggregate";e={(Get-NcVol $_.Volume).Aggregate}} | Format-Table&lt;/PRE&gt;
&lt;P&gt;Donny&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Aug 2019 21:50:41 GMT</pubDate>
      <guid>https://community.netapp.com/t5/ONTAP-Discussions/How-to-combine-Get-NcSnapshot-amp-Get-NcAggr-in-a-Powershell-script/m-p/150598#M33516</guid>
      <dc:creator>donny_lang</dc:creator>
      <dc:date>2019-08-29T21:50:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine Get-NcSnapshot &amp; Get-NcAggr in a Powershell script</title>
      <link>https://community.netapp.com/t5/ONTAP-Discussions/How-to-combine-Get-NcSnapshot-amp-Get-NcAggr-in-a-Powershell-script/m-p/150620#M33518</link>
      <description>&lt;P&gt;Hi Donny &amp;amp; Gidi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Many thanks for chipping&amp;nbsp; in and helping out. Much appreciated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://community.netapp.com/t5/user/viewprofilepage/user-id/30220"&gt;@Donny&lt;/a&gt;: I used the command you suggested in the following script: It will be interactive, i.e it will ask user to input the 'days older than snaps'&amp;nbsp; in integer and depending on that it will produce result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Its working fine without aggr field, my intention is to get aggregte against the volume names.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;I tried this, and it runs but never ends [goes in loop kinds] I had to kill it, but it produced the resutls in excel, however the aggregate colume puts all the aggregates in each cell instead of just one aggregate against a column name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any idea how can I get this fixed ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Get-NcSnapshot | ForEach-Object {&lt;BR /&gt;$x = "" | Select @{Name="SnapName";Expression={$_.Name}},Created, Vserver, Volume, Total_GB, Cumulative_GB, Dependency, @{l="Aggregate";e={(Get-NcVol $_.Volume).Aggregate}}&lt;BR /&gt;$x.SnapName = $_.Name&lt;BR /&gt;$x.Created = $_.Created&lt;BR /&gt;$x.Vserver = $_.Vserver&lt;BR /&gt;$x.Volume = $_.Volume&lt;BR /&gt;$x.Total_GB = $_.Total&lt;BR /&gt;$x.Cumulative_GB = $_.Cumulative&lt;BR /&gt;$x.Dependency = $_.Dependency&lt;BR /&gt;$x.Total_GB = [Math]::Round($_.Total / 1GB, 2)&lt;BR /&gt;$x.Cumulative_GB = [Math]::Round($_.Cumulative / 1GB, 2)&lt;BR /&gt;$x&lt;BR /&gt;} | Where {$_.Created -lt (Get-Date).AddDays(-$value)} | Export-CSV -Path "C:\blah\blah\snaps.csv"&lt;/P&gt;</description>
      <pubDate>Fri, 30 Aug 2019 11:46:50 GMT</pubDate>
      <guid>https://community.netapp.com/t5/ONTAP-Discussions/How-to-combine-Get-NcSnapshot-amp-Get-NcAggr-in-a-Powershell-script/m-p/150620#M33518</guid>
      <dc:creator>Ontapforrum</dc:creator>
      <dc:date>2019-08-30T11:46:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine Get-NcSnapshot &amp; Get-NcAggr in a Powershell script</title>
      <link>https://community.netapp.com/t5/ONTAP-Discussions/How-to-combine-Get-NcSnapshot-amp-Get-NcAggr-in-a-Powershell-script/m-p/150625#M33522</link>
      <description>&lt;P&gt;Hi Guys,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think&amp;nbsp; I understood the issue but don't know how to fix it. I am sure there is simple fix for this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Whats happening is : Get-NcVol is&amp;nbsp; looking at $_.Volume&amp;nbsp; and therefore it is going through all the volumes that is paased by Get-NcSnapshot and then getting all the aggreagtes and inserting entire list in single cell against each snapshot. Instead of just taking one volume at a time for the respective snapshot and then getting aggregate name for that one volume alone and then next one and so on.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Aug 2019 13:35:32 GMT</pubDate>
      <guid>https://community.netapp.com/t5/ONTAP-Discussions/How-to-combine-Get-NcSnapshot-amp-Get-NcAggr-in-a-Powershell-script/m-p/150625#M33522</guid>
      <dc:creator>Ontapforrum</dc:creator>
      <dc:date>2019-08-30T13:35:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine Get-NcSnapshot &amp; Get-NcAggr in a Powershell script</title>
      <link>https://community.netapp.com/t5/ONTAP-Discussions/How-to-combine-Get-NcSnapshot-amp-Get-NcAggr-in-a-Powershell-script/m-p/150627#M33523</link>
      <description>&lt;P&gt;Yeah, the "ForEach-Object" in your code is causing that particular behavior. I reworked it a bit, try this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Get-NcSnapshot | Where-Object { $_.Created -lt (Get-Date).AddDays($value) } | Select-Object @{l = "SnapName"; e = {$_.Name}}, Created, Vserver, Volume, Dependency, `
	@{l = "Cumulative_GB"; e = {$([Math]::Round($_.Cumulative / 1GB, 2)).ToString()}}, @{l = "Total_GB"; e = {$([Math]::Round($_.Total / 1GB, 2)).ToString() }}, `
	@{l = "Aggregate"; e = { (Get-NcVol $_.Volume).Aggregate } } | Export-CSV -Path "\destination\path\snaps.csv"&lt;/PRE&gt;
&lt;P&gt;This returned good data in my lab, so hopefully it works for you too. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Aug 2019 14:21:24 GMT</pubDate>
      <guid>https://community.netapp.com/t5/ONTAP-Discussions/How-to-combine-Get-NcSnapshot-amp-Get-NcAggr-in-a-Powershell-script/m-p/150627#M33523</guid>
      <dc:creator>donny_lang</dc:creator>
      <dc:date>2019-08-30T14:21:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine Get-NcSnapshot &amp; Get-NcAggr in a Powershell script</title>
      <link>https://community.netapp.com/t5/ONTAP-Discussions/How-to-combine-Get-NcSnapshot-amp-Get-NcAggr-in-a-Powershell-script/m-p/150628#M33524</link>
      <description>&lt;P&gt;Hi Donny,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You are absolutely star. Didn't have to edit anything, just copy pasted and it worked like a charm.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Wow..that's a beauty of community support, I don't have to break my head for something for which there are experts available already.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just being a little more greedy, just a query : I can easily take this aggr name and check it's used %&amp;nbsp; But, I was wondering if I can feed in - Get-NcAggr and pull in $_.Aggregate from the Get-NcVol ouput and calcualte the % used, total , availabe in the same excel. I want to know how to insert another Get-NcAggr in that script.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Many thanks again.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You rock.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;-Ash&lt;/P&gt;</description>
      <pubDate>Fri, 30 Aug 2019 15:43:44 GMT</pubDate>
      <guid>https://community.netapp.com/t5/ONTAP-Discussions/How-to-combine-Get-NcSnapshot-amp-Get-NcAggr-in-a-Powershell-script/m-p/150628#M33524</guid>
      <dc:creator>Ontapforrum</dc:creator>
      <dc:date>2019-08-30T15:43:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine Get-NcSnapshot &amp; Get-NcAggr in a Powershell script</title>
      <link>https://community.netapp.com/t5/ONTAP-Discussions/How-to-combine-Get-NcSnapshot-amp-Get-NcAggr-in-a-Powershell-script/m-p/150629#M33525</link>
      <description>&lt;P&gt;******Sorry I accidently clicked the wrong reply message for Accepted solution ***** Can Moderator please undo this ?&lt;/P&gt;</description>
      <pubDate>Fri, 30 Aug 2019 15:46:34 GMT</pubDate>
      <guid>https://community.netapp.com/t5/ONTAP-Discussions/How-to-combine-Get-NcSnapshot-amp-Get-NcAggr-in-a-Powershell-script/m-p/150629#M33525</guid>
      <dc:creator>Ontapforrum</dc:creator>
      <dc:date>2019-08-30T15:46:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine Get-NcSnapshot &amp; Get-NcAggr in a Powershell script</title>
      <link>https://community.netapp.com/t5/ONTAP-Discussions/How-to-combine-Get-NcSnapshot-amp-Get-NcAggr-in-a-Powershell-script/m-p/150674#M33541</link>
      <description>&lt;P&gt;Done, thanks for letting us know and thanks&amp;nbsp;&lt;a href="https://community.netapp.com/t5/user/viewprofilepage/user-id/77625"&gt;@donny_lang&lt;/a&gt;&amp;nbsp;for helping out!&lt;/P&gt;</description>
      <pubDate>Tue, 03 Sep 2019 12:56:03 GMT</pubDate>
      <guid>https://community.netapp.com/t5/ONTAP-Discussions/How-to-combine-Get-NcSnapshot-amp-Get-NcAggr-in-a-Powershell-script/m-p/150674#M33541</guid>
      <dc:creator>AlexDawson</dc:creator>
      <dc:date>2019-09-03T12:56:03Z</dc:date>
    </item>
  </channel>
</rss>

