<?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 Using Data ONTAP PowerShell Toolkit objects in C# Managed Code in Microsoft Virtualization Discussions</title>
    <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Using-Data-ONTAP-PowerShell-Toolkit-objects-in-C-Managed-Code/m-p/38358#M1749</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, Tom.&amp;nbsp; When you invoke Connect-NaController and the login succeeds, the NaController instance is stored in $global:CurrentNaController, so as long as you continue using the same runspace, subsequent cmdlets should use that.&amp;nbsp; Most Toolkit cmdlets also provide a -Controller parameter, so you can explicitly provide the controller instance (such as when looping through a list of controllers).&amp;nbsp; Either way, you should be able to use the Toolkit from C# as you are doing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And yes, it's worthwhile.&amp;nbsp; Microsoft suggests writing new management applications in PowerShell and then invoking that functionality from the UI layer.&amp;nbsp; That guarantees separability so one may test the UI apart from the underlying functions.&amp;nbsp; And the resulting product is then fully accessible from PowerShell scripts, so your users can script your application in ways you probably haven't even considered.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 06 Sep 2011 13:53:21 GMT</pubDate>
    <dc:creator>cknight</dc:creator>
    <dc:date>2011-09-06T13:53:21Z</dc:date>
    <item>
      <title>Using Data ONTAP PowerShell Toolkit objects in C# Managed Code</title>
      <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Using-Data-ONTAP-PowerShell-Toolkit-objects-in-C-Managed-Code/m-p/38354#M1748</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Apologies if this question isn't appropriate to this forum as the problem may be more my lack of .Net knowledge than anything else but I'm trying to use the DataONTAP powershell module from within a C# windows application I'm writing to automate/simplify some operational checks we currently run manually (snapmirror lags, snapshot space, vol usage, etc).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm trying (for example) to connect to a controller (using the Connect-NaController cmdlet) and return it as an NetApp.Ontapi.Filer.NaController object. In previous powershell scripts we've produced we've done wrapped that in a function, called it at the start of the script and used the resultant $filer variable as the -Controller parameter when calling subsequent cmdlets like Get-NaSnapmirror, GetNaVol, etc.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#Connects to and returns a NetApp Filer controller object&lt;/P&gt;&lt;P&gt;function ConnectNAFiler($filerfqdn)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; try&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $filer = Connect-NaController $filerfqdn -ErrorAction "stop"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $filername = $filer.Name&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $filerport = $filer.Port&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $filerprot = $filer.Protocol&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Write-Log "Successfully connected to $filername`:$filerport via $filerprot"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; catch&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Write-Log "Unable to connect to $filerfqdn - Exiting"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CleanUp&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Write-Log "### Exiting $me ###"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return $filer&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In my limited grasp of C# I go add the DataONTAP module to my session, create a runspace, invoke Connect-NaController and see that I get back a PSObject with a base type of [0] = "NetApp.Ontapi.Filer.NaController" and I can enumerate properties just as I would in PS. My stumbling block from here is how would I use that object in subsequent cmdlets later in the managed code? Can I just store it somewhere and append as a parameter as in PS?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;class DataONTAP&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public static void ConnectNAFiler()&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; InitialSessionState initialSession = InitialSessionState.CreateDefault(); &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; initialSession.ImportPSModule(new[] { "DataONTAP" });&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Runspace runspace = RunspaceFactory.CreateRunspace(initialSession); &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; runspace.Open(); &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; RunspaceInvoke invoker = new RunspaceInvoke(runspace); &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Collection&amp;lt;PSObject&amp;gt; results = invoker.Invoke("Connect-NaController myfiler");&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; foreach (PSObject ps in results)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Debug.WriteLine(ps.Properties["name"].Value);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Debug.WriteLine(ps.Properties["port"].Value);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Debug.WriteLine(ps.Properties["protocol"].Value);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Debug.WriteLine(ps.Properties["version"].Value);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is this even worthwhile? I've seen some great examples in the manageability SDK to using the APIs to do this kind of thing but we'd like to go down the "C# managed PS" route to 1) preserve our investment in what we've done in PS and 2) we're hearing that stuff like the Exchange 2010 tools and the AD Admin Center are just wrappers for PS code.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Jun 2025 06:46:54 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Using-Data-ONTAP-PowerShell-Toolkit-objects-in-C-Managed-Code/m-p/38354#M1748</guid>
      <dc:creator>tom_maher</dc:creator>
      <dc:date>2025-06-05T06:46:54Z</dc:date>
    </item>
    <item>
      <title>Using Data ONTAP PowerShell Toolkit objects in C# Managed Code</title>
      <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Using-Data-ONTAP-PowerShell-Toolkit-objects-in-C-Managed-Code/m-p/38358#M1749</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, Tom.&amp;nbsp; When you invoke Connect-NaController and the login succeeds, the NaController instance is stored in $global:CurrentNaController, so as long as you continue using the same runspace, subsequent cmdlets should use that.&amp;nbsp; Most Toolkit cmdlets also provide a -Controller parameter, so you can explicitly provide the controller instance (such as when looping through a list of controllers).&amp;nbsp; Either way, you should be able to use the Toolkit from C# as you are doing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And yes, it's worthwhile.&amp;nbsp; Microsoft suggests writing new management applications in PowerShell and then invoking that functionality from the UI layer.&amp;nbsp; That guarantees separability so one may test the UI apart from the underlying functions.&amp;nbsp; And the resulting product is then fully accessible from PowerShell scripts, so your users can script your application in ways you probably haven't even considered.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Sep 2011 13:53:21 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Using-Data-ONTAP-PowerShell-Toolkit-objects-in-C-Managed-Code/m-p/38358#M1749</guid>
      <dc:creator>cknight</dc:creator>
      <dc:date>2011-09-06T13:53:21Z</dc:date>
    </item>
    <item>
      <title>Using Data ONTAP PowerShell Toolkit objects in C# Managed Code</title>
      <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Using-Data-ONTAP-PowerShell-Toolkit-objects-in-C-Managed-Code/m-p/38367#M1750</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Hi Clinton and thank you for taking the time to address my post. I'd completely forgotten the NaController gets set globally.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Where you say "Microsoft suggests..." is there any public visibility of this? I only ask as I'm finding resource on MSDN &amp;amp; Technet pretty scarce. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Sep 2011 09:27:18 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Using-Data-ONTAP-PowerShell-Toolkit-objects-in-C-Managed-Code/m-p/38367#M1750</guid>
      <dc:creator>tom_maher</dc:creator>
      <dc:date>2011-09-07T09:27:18Z</dc:date>
    </item>
    <item>
      <title>Using Data ONTAP PowerShell Toolkit objects in C# Managed Code</title>
      <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Using-Data-ONTAP-PowerShell-Toolkit-objects-in-C-Managed-Code/m-p/38372#M1751</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Tom, my comments regarding PowerShell are based on my attendance at several conferences the last few years.&amp;nbsp; I had the opportunity to meet with PowerShell inventor &lt;A href="http://www.microsoft.com/presspass/exec/de/snover/default.mspx" target="_blank"&gt;Jeffrey Snover&lt;/A&gt; and his team on each of those occasions, and their message was consistent: invest in PowerShell, build new applications on top of it, and that investment will pay off in spades.&amp;nbsp; Now that Snover is lead architect of Windows Server, I'd say he is well positioned to keep that promise.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Sep 2011 18:43:16 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Using-Data-ONTAP-PowerShell-Toolkit-objects-in-C-Managed-Code/m-p/38372#M1751</guid>
      <dc:creator>cknight</dc:creator>
      <dc:date>2011-09-07T18:43:16Z</dc:date>
    </item>
    <item>
      <title>Using Data ONTAP PowerShell Toolkit objects in C# Managed Code</title>
      <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Using-Data-ONTAP-PowerShell-Toolkit-objects-in-C-Managed-Code/m-p/38380#M1754</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you look carefully, MSFT is using this strategy in their own tools.&amp;nbsp; Exchange was the leader here but all other MSFT management tools are headed this way.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PowerShell support is mandated as part of Microsoft's Common Engineering Criteria (CEC) which is public:&amp;nbsp; &lt;A href="http://www.microsoft.com/cec/en/us/default.aspx" target="_blank"&gt;http://www.microsoft.com/cec/en/us/default.aspx&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Alex&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Sep 2011 19:51:46 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Using-Data-ONTAP-PowerShell-Toolkit-objects-in-C-Managed-Code/m-p/38380#M1754</guid>
      <dc:creator>jausch</dc:creator>
      <dc:date>2011-09-07T19:51:46Z</dc:date>
    </item>
    <item>
      <title>Using Data ONTAP PowerShell Toolkit objects in C# Managed Code</title>
      <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Using-Data-ONTAP-PowerShell-Toolkit-objects-in-C-Managed-Code/m-p/38388#M1755</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you very much for the feedback guys. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Clinton, I first came across Mr Snover's name on a blog post extolling (ironically enough) the DataONTAP module which led us to other blog posts that suggest using WPF to lay out your GUI over pure PS and that's more or less led us to where we think we want to be.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Alex, thank you very much for the link to the CEC - that's exactly what I was after to formally justify adopting managed PS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Sep 2011 08:04:08 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Using-Data-ONTAP-PowerShell-Toolkit-objects-in-C-Managed-Code/m-p/38388#M1755</guid>
      <dc:creator>tom_maher</dc:creator>
      <dc:date>2011-09-08T08:04:08Z</dc:date>
    </item>
  </channel>
</rss>

