<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://weblogs.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>PowerShell and using .Net enum types</title><link>http://weblogs.asp.net/soever/archive/2006/12/11/powershell-and-using-net-enum-types.aspx</link><description>[NOTE: Because this page is the first hit in Google when you search on Powershell + enum, and I landed on this page too often myself, I decided to expand the page with some additional information] Scripting is heaven when you can utilize the complete</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>re: PowerShell and using .Net enum types</title><link>http://weblogs.asp.net/soever/archive/2006/12/11/powershell-and-using-net-enum-types.aspx#6640523</link><pubDate>Wed, 24 Sep 2008 18:00:51 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6640523</guid><dc:creator>James Kendig</dc:creator><author>James Kendig</author><description>&lt;p&gt;Can you please post your final code for this piece including the value of your variable $viewfields.&lt;/p&gt;
&lt;p&gt;I am trying to create a new Calendar View inside of a Calendar List and have not been able to successfully figure out the syntax.&lt;/p&gt;
&lt;p&gt;Thanks.&lt;/p&gt;
&lt;p&gt;James&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6640523" width="1" height="1"&gt;</description></item><item><title>re: PowerShell and using .Net enum types</title><link>http://weblogs.asp.net/soever/archive/2006/12/11/powershell-and-using-net-enum-types.aspx#6285457</link><pubDate>Tue, 17 Jun 2008 07:43:34 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6285457</guid><dc:creator>Alex</dc:creator><author>Alex</author><description>&lt;p&gt;Found it: nested types should be referenced using &amp;lt;namespace&amp;gt;.&amp;lt;enclosing type&amp;gt;+&amp;lt;nested type&amp;gt;&lt;/p&gt;
&lt;p&gt;i.e. in my case&lt;/p&gt;
&lt;p&gt;[Microsoft.SharePoint.SPViewCollection+SPViewType]::Gantt&lt;/p&gt;
&lt;p&gt;Cheers,&lt;/p&gt;
&lt;p&gt;Alex&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6285457" width="1" height="1"&gt;</description></item><item><title>re: PowerShell and using .Net enum types</title><link>http://weblogs.asp.net/soever/archive/2006/12/11/powershell-and-using-net-enum-types.aspx#6283473</link><pubDate>Mon, 16 Jun 2008 20:16:51 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6283473</guid><dc:creator>Alex</dc:creator><author>Alex</author><description>&lt;p&gt;Hi Serge,&lt;/p&gt;
&lt;p&gt;thanks for this. I am trying to create a view on a SharePoint list using PowerShell. One of the parameters is the type of the view, and in C# it should be of type Microsoft.SharePoint.SPViewCollection.SPViewType. So that is an enum within a class.&lt;/p&gt;
&lt;p&gt;This is what I've got:&lt;/p&gt;
&lt;p&gt;PS&amp;gt; $asm = reflection.assembly]::loadwithpartialname(&amp;quot;microsoft.sharepoint&amp;quot;)&lt;/p&gt;
&lt;p&gt;... stuff to initialise $splist and $spfields&lt;/p&gt;
&lt;p&gt;PS&amp;gt; $splist.Views.Add(&amp;quot;New view&amp;quot;, $viewFields, '&amp;lt;OrderBy&amp;gt;&amp;lt;FieldRef Name=&amp;quot;ID&amp;quot; /&amp;gt;&amp;lt;/OrderBy&amp;gt;', 100, 1, 1, [Microsoft.SharePoint.SPViewCollection.SPViewType] &amp;quot;Html&amp;quot;, 0)&lt;/p&gt;
&lt;p&gt;The last line gives the error &amp;quot;Unable to find type [Microsoft.SharePoint.SPViewCollection.SPViewType]: make sure that the assembly containing this type is loaded.&amp;quot;&lt;/p&gt;
&lt;p&gt;If I try to fetch the type from the assembly like this:&lt;/p&gt;
&lt;p&gt;PS &amp;gt; $asm.GetType(&amp;quot;Microsoft.SharePoint.SPViewCollection.SPViewT&lt;/p&gt;
&lt;p&gt;ype&amp;quot;, 1, 1)&lt;/p&gt;
&lt;p&gt;Exception [...] &amp;quot;Could not load type 'Microso&lt;/p&gt;
&lt;p&gt;ft.SharePoint.SPViewCollection.SPViewType' from assembly 'Microsoft.SharePoint,&lt;/p&gt;
&lt;p&gt; Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'.&amp;quot;&lt;/p&gt;
&lt;p&gt;In contrast the following works:&lt;/p&gt;
&lt;p&gt;PS&amp;gt; $asm.GetType(&amp;quot;Microsoft.SharePoint.SPViewCollection&amp;quot;, 1, 1)&lt;/p&gt;
&lt;p&gt;I can't get this to work, perhaps you have some tips?&lt;/p&gt;
&lt;p&gt;Thanks.&lt;/p&gt;
&lt;p&gt;Alex&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6283473" width="1" height="1"&gt;</description></item><item><title>re: PowerShell and using .Net enum types</title><link>http://weblogs.asp.net/soever/archive/2006/12/11/powershell-and-using-net-enum-types.aspx#1212282</link><pubDate>Mon, 11 Dec 2006 13:54:42 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:1212282</guid><dc:creator>CumpsD</dc:creator><author>CumpsD</author><description>&lt;p&gt;Have you tested it with bitwise added enums as well? :)&lt;/p&gt;
&lt;p&gt;Like the regexoptions.&lt;/p&gt;
&lt;p&gt;Enum1 | Enum2&lt;/p&gt;
&lt;p&gt;My guess is it would work when passed as &amp;quot;Enum1 Enum2&amp;quot;, but I'm not sure. Might be interesting to test since you're dealing with powershell and enums. (I haven't tried powershell yet)&lt;/p&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=1212282" width="1" height="1"&gt;</description></item></channel></rss>