Showing posts with label MSDN. Show all posts
Showing posts with label MSDN. Show all posts

Wednesday, May 18, 2016

Finding Type Information in PowerShell

On frequent occasions, I find myself using a cmdlet and needing more information about the objects that cmdlet produces. The details are in Microsoft’s MSDN library, but it can be hard to use the GUI to find it. Fortunately, I found a cool way of dealing with this. I found the trick on the Internet but I really can not remember where I found it.

The trick is simple: I use some Type XML to extend all objects with a new script method called MSDN. If I create an object – I can assign it to a variable and just call the .MSDN() method on any occurrence.  Suppose I did a Get-ChildItem against the Certificate Provider and needed more details on the object returned. I just do this:

$Certs = Get-ChildItem Cert:\CurrentUser\My
$Certs[0].MSDN()

The MSDN() method, something I’ve added in, then brings up Internet Explorer and nvigates to the appropriate page in the MSDN library. Which is: https://msdn.microsoft.com/library/System.Security.Cryptography.X509Certificates.X509Certificate2.ASPX.

But how did that method come about – you might ask! Easy – it’s just a bit of type XML I add to each system I use. I just add an xml file and reference it in my PowerShell profile. The XML file looks like this:

<Types>
  <Type>
    <Name>System.Object</Name>
    <Members>
      <ScriptMethod>
        <Name>MSDN</Name>
        <Script>
           if (($global:MSDNViewer -eq $null) –or
              ($global:MSDNViewer.HWND -eq $null))
           {$global:MSDNViewer = new-object -ComObject InterNetExplorer.Application}
              $Uri = "
http://msdn2.microsoft.com/library/" + $this.GetType().FullName + ".ASPX"
              $global:MSDNViewer.Navigate2($Uri)
              $global:MSDNViewer.Visible = $TRUE
      </Script>
      </ScriptMethod>
    </Members>
  </Type>
</Types>

I have saved this into a file (I saved it as c:\foo\my.types.ps1.xml) then in each PowerShell profile I just add it in:

Update-TypeData -appendPath C:\foo\my.types.ps1xml

And from then on, you can just use the MSDN method on just about any type. It’s not perfect – sadly there are types/classes that do not appear documented in MSDN (or at least now where this little XML trick can find it).

If you know where this came from, Please comment – I just can’t remember where I found it!

Wednesday, February 20, 2013

MSDN/TechNet Library–The Classic Skin is No More

For those of you who use the MSDN and TechNet library content, you may have noticed that Microsoft has changed the UI of these subsites: http://msdn.microsoft.com/library and http://technet.microsoft/com/library. . These are essentially the same site, that point to different databases. Some years ago, the sites were updated to have several skins: lightweight, script free and classic. I’ve been a user of Classic since forever and was very surprised to see that MS has decided to retire the classic skin.

In the MSDN forum, this decision generated a lot of discussion: see http://social.msdn.microsoft.com/Forums/en-US/libraryfeedback/thread/bbfb492b-4c85-4e8d-ab44-423c4050089e/ for the thread. A user, Victor Araya, posted on Jan 24th claiming to be the PM responsible for the user experience of these sites. He laid out his argument trying to ‘address some of the concerns’.  The feedback on that post was interesting in that not one of the users who follows up this post either agree with him or like the alternative skin. Not one. Comments like “the Lightweight display is a complete failure”, “Lightweight is simply no where near as useable as classic”, “the lightweight view is just washed out and unappealing to the point I really don't want to use it”,” Microsoft really seems to be taking steps to alienate it's developers or just make our work harder” etc.

For me, the change means losing all the community content metrics and tag information. As a community content contributor for both the TechNet and MSND libraries, in fact the largest contributor by a mile, I am sad to see all reference to the thousands of hours I’ve spend curating the content just thrown away.  It’s like all that work has just been for nothing. Heck, I didn’t even get a mail giving me a heads up that all reference to my work would vanish. Thanks Victor and your team for such a great job.

But perhaps the saddest comment comes from a very long time MVP, Cindy Meister. She says: You have to wonder what MSDN does with all the money people pay for their subscriptions. Good point Cindy.

So with such positive feedback – what does Microsoft do? Most companies would have read the feedback and at least gone into explain mode. But no – this is not how Microsoft reacted to the bad feedback. Instead of engaging the community,  we’ve not had a single further response from either ‘Victor’ or any other MS employee. I find the lack of response from Microsoft highly disappointing. And despite every poster asking MS to keep the classic skin, the classic skin is no more – it’s gone. And along with the skin itself, we have lost quite a lot of great information and as well as the improved usability if offered. 

It is sad is that no one from Microsoft has taken the time or made the effort to follow up on the many negative comments. It’s like they have made the decision and that’s that. No amount of sane and sensible paying customer feedback will change their minds. So we suffer. IMHO, Someone at Microsoft needs to listen to the community better. If I were Victor’s boss and read this thread, I’d be very tempted to let him follow his career objectives elsewhere and replace him with someone who gets the needs of the community.

What a sad day!

Friday, July 02, 2010

PowerShell and XML Element Attributes

I’ve been playing a bit this week with XML and PowerShell. As you no doubt know, PowerShell has first class XML support built in. To see more about that, see Tobias’s Ebook Chapter on XML and PowerShell. My task this week was to work with attributes that can appear inside an XML tag. I was using the .NET XML class System.XML.XMLElement and it’s various attribute related method.

As noted in MSDN, are a node in a DOM (XML) document. These elements can have attributes which you can associate with the element. For example, consider the following XML element:

<book genre='novel' ISBN='1-861001-57-5'>
<title>Pride And Prejudice</title>
</book>"

Such an element would normally be part of a much larger collection (et <books></books>), but for the purposes of playiing with element attributews, you can load it and then treated as an XML document with elements (albeit not many). You can load this document like this (and yes, there are a  bunch more ways!)

$Doc = New-Object System.Xml.XmlDocument 
$Doc.LoadXml("<book genre='novel' ISBN='1-861001-57-5'>" + 
             "   <title>Pride And Prejudice</title>" + 
             "</book>"

In the XML document, the book element has two attributes, genre and ISBN. Each attribute has the simple format (in the XML) of <attribute name>=<attributevalue>.

Once you load the document, you can do things like:

  • Check whether an element has a particular named attribute
  • Get the value of an attribute
  • Remove an attribute
  • Set and attribute

To do this in Powershell you would do something like this, eg to set an attribute:

$Root = $Doc.DocumentELement
$Root.SetAttribute("attributename","value")

In richer XML scripts the attributename and the value would be held in a variable (that you in turn might have obtained from another XML document).

I’ve written several sample scripts over on the PowerShell scripts blog, which re-implement a number of MSDN attribute handling C# samples:

  • Get-XMLAttribute.ps1 – this script loads the XML then checks to see if the element has an attribute and if so, the code prints out the value of the attribute.
  • Remove-XMLAttribute and Remove-XMLAttributeAt.ps1 – these scripts load the XML and then remove the attribute, but using different .NET methods (i.e. RemoveAttribute and RemoveAttributeAt). Using the Remove AttributeAt, where you specify the position of the attribute, and not the name, is potentially dangerous. I have the t-shirt on that one! 
  • Set-XMLAttribute.ps1 – this script as the name might imply, loads the XML and adds an attribute to the element.

Fun stuff!

Technorati Tags: ,,,

Saturday, December 26, 2009

Unified Communications Developer Portal

Microsoft's push into the world of Unified Communications continues with the launch of the Unified Communications Developer Portal.  This MSDN portal is part of the Office Development Center, and is designed to feature links and resources for developers wanting to get into UC.

As I write this updated post, there some interesting feature articles, including Detecting the State of the Office Communications Server and Building UCMA Installers.

This is a great site for developers (and admins that secretly want to be developers!) to learn more about developing in the UC space.

Sunday, November 01, 2009

What Happened To The Post Counts on the MSDN and TechNet Wikis?

I’m a fairly heavy contributor to the MSDN and TechNet Wikis - also known as MSDN and TechNet Community Content. I started posting there pretty much ever since Microsoft setup this feature a couple of years ago. My contribution has included over 10,000 posts (just over 7500 to MSDN and over 2800 to TechNet). I wrote about the MSDN wiki in August.

I do not know if it’s a short term glitch or a more major change – but the post counts have been updated in a significantly downward fashion. TechNet shows just 1297 posts, while on MSDN just 3927) – thus I’ve lost around half my post count. At the time I wrote the august post, I had over 6500 posts credited, but now it’s a LOT lower.

MSDN/TechNet: what’s happened??

Wednesday, October 21, 2009

MSDN Has A New Look and Feel

I spend time on the MDSN Site, particularly the MSDN Library sub-site where I’ve added a few PowerShell scripts as well as editing the content that is added. Just recently, the site has had a bit of a make over. The “MSDN-RED” logo is replaced wiht a more stylish blue colour, along with the opportunity to change your view of the site.

From FireFox, I have a new pop up at the bottom right hand corner of my browser window:

image

The “old” view, Classic is what you are used to, although with new colours. It is the view I will use going forward. Lightweight beta provides what it says, a much more lightweight feel. ScriptFree is even nicer (IMHO) to look at.  And being smaller pages, download times are much snappier.

But what both these two new views omit is all the community contnet (i.e. Community Content) as contained in Classic View. From the Script page, community added page tags are R/O, and there appears to be no way to see or edit Community Content (from both LightWeight and Script Free skins). And the big orange Switch View button from Classic view is pretty ugly and distracting – worse, there appears to be no way to tell it: I’m happy with what I see and please go away.  Or at least a more subtle control perhaps in the title bars like in the other views.

For casual users, or those on lightweight (aka celluar) networks, it’s a nice touch. Shame about losing the community content.

Saturday, August 29, 2009

The MSDN Wiki – a look after nearly 6500 edits

Last summer, I posted a blog article about the MSDN wiki, better known as MSDN Community Content (there’s also an equivalent set of content around IT Pro type information, namely Technet  Community Content. This morning I got a comment on that entry which complained about a) not being able to find stuff and b) that the community content idea had been killed. I posted a response to that comment – the Community content is still alive and kicking. In the past year, I’ve added over 6000 updates, the latest of which was a few minutes ago! I’ve also added around 2500 edits to the TechNet equivalent, or nearly 9000 edits in total – and I’m not even an MVP!

The Community Content represents some really great information – and not a few criticisms where the content (or the product!) is at fault. Sadly, as I noted last year, there is a degree of vandalism on this site, which has grown somewhat over the past year. I am fairly ruthless (although as not up to date as I’d want!) with reviewing new comments and removing what I call “non-content”, as well as duplicate posts which some times get made. I also try to ensure good tags. One trend that has accelerated is for posters to see the MSDN community content as a place to ask questions – a couple of posters including my self, point them to the community forums and the Microsoft newsgroups. I also try to ensure the tags on the each community content are relevant.

As ever in publishing, the MSDN content contains errors – usually minor typos, etc. While these are regatable, given the sheer scale of the MSDN (and TechNet) library, these are probably inevitable. Thanks to the sharp eyes in the community, these are found, and have been tagged “Contentbug”. Microsoft are slowly working through these and updating the content proving that the community review process is working, albeit much slower than I’d like.

All in all, the MSDN and TechNet Community Content  are fantastic resources, and are growing daily. Thanks to the MSDN/Technet content teams for providing the platform and working with the community to improve the content

Saturday, December 27, 2008

MSDN Code Search Preview (http://msdn.krugle.com/)

Looking at the MSDN Library site tonight and I noticed a new “Feature Spotlight” – point to a new site that enables you to search for code inside MSDN. The site enables  you to search for code, and if you find something of interest, you can book mark it, or create a unique URL to the appropriate page. It’s clearly early days for this site. You can’t yet search for  code on the MSDN Forums, the MSDN Code Gallery or Codeplex.

Another downside – under Language, there’s no PowerShell. There’s Perl and Ruby and Python and C++ and  C#, etc – but no PowerShell. :-(  You can filter on PowerShell and find some PowerShell related code. Shame no one in MSDN recognises PowerShell as a language!

Technorati Tags: ,

Sunday, October 05, 2008

MSDN/TechNet Sites are back up!

Yesterday, I noted that Microsoft’s TechNet and MSDN Sites were unreachable for me.Today, they seem back up. Not sure what the outage was due to, but they’re live now.

I hate long (eg 1 day or more) outages where there seems to be no warning, or no exlanation. MSDN/TechNet site management needs a Microsoft Operations Framework course in Change Management.

Technorati Tags: ,,,

Friday, July 18, 2008

Reducing Vandalism on Public Wiki Sites

I’ve been reading an interesting article from the New Your times on Wikipedia’s experiment to cut down vandalism. The approach is rather simplistic: get the community to check the update for lack of valdalism before the article is made available for general use. It’s a bit more complex than that, but basically by making most posts subject to review before  general posting, vandals are much less likely to see their work. The hope is the vandals just pack up and move along. It’ll be interesting to see what success this approach has.

I contribute to MS’s TechNet and MSDN wikis (aka community contributions) where vandalism also occurs. The vast majority of what I’m seeing is pretty minor and there’s not a lot of it: 3 to 5 posts a day with what I call “non content” such as an article saying “great” or just containing an email address or a web link. I can see these posts by following the RSS feed from the two sites –but all too often, by the time I hit the actual web site, those non-content articles are gone or un-vandalised. As a result, the quality of the contrubutions is not really affected by vandalism.

I wonder if a ‘checking’ approach would improve the quality of the MSDN and Technet wiki sites?

Sunday, June 29, 2008

MSDN Wiki - 1100 edits later

I've been contributing to the MSDN Wiki for a bit over a year. After an edit tonight, I see I've hit 1100 updates thus far, far in advance of the number 2 contributor!

The purpose of the Wiki is to enable the community to add content. This can be in the form of code samples, deeper explanations, or external references. I do see a bit of graffiti from time to time but thankfully the admins on the site are pretty quick to remove any vandalism (or 'non-content' as I call it).

My adventure with the Wiki started one Sunday afternoon a bit over a year ago. I was looking at a C# code sample on the MSDN site and was trying to convert it into PowerShell. Since PowerShell was built on .NET, it was supposed to be easy to just dig in and use the framework. But I just didn't get it - I was missing something. If I recall, I was trying to play around with the XML functions in PowerShell and just could not work out what was going on!

I posted a query in the most excellent PowerShell MS newsgroup and in under an hour, Keith Hill posted a reply that knocked the fog from my eyes and suddenly I was able to access a .NET Class. So I posted the sample, then a few more. It was a fun day. Then I posted some more and then more - my aim was to put the "PowerShell" tag at number 1 in the tag cloud.

Since then, I've posted just short of 300 samples showing how you can use PowerShell to access various parts of the .NET framework. Whilst working on the Microsoft PowerShell course, I delved into COM and WMI too!

I've also been updating my (and a few other) posts with better tagging. I've not been successful, yet, in the goal of getting PowerShell to be the number 1 tag: 695 posts are tagged as 'contentbug' with only 276 tagged as PowerShell so far.I probably need to check some of my posts to ensure they're tagged correctly.

I've found this most rewarding - I know a lot more about how to use PowerShell to access the core system functions, as well as knowing more about how those functions work. As a trainer, this have been invaluable in prepping up to teach PowerShell. It's also a wonderful reference for others to build on, as I've started to see.

A great challenge to trainers wanting to learn to teach PowerShell well - add a few samples yourself. Work with the examples from the course. Then find an undocumented class/method/member, etc. and develop some new samples. Carry on for a bit and who knows, your name may be in the top contributors list.

Monday, January 28, 2008

MSDN Library Community Content and PowerShell

Microsoft turned on the community content feature of the MSDN site in late 2006, just over a year ago. That meant users could add content to MSDN in the way of additional samples,commentary, best practices, and even just simple typos! If you navigate to the root of the MSDN library page(http://msdn2.microsoft.com/en-us/library/default.aspx) you can see the statistics relating to the community content.

Thus far, I've added over 120 samples - mainly using PowerShell with a variety of components, including COM, WMI and .NET. I enjoy being one of the top contributors! I wonder if anyone over at Microsoft has noticed!

Over the past couple of days, I've been using PowerShell with several WMI and .NET objects and tonight I'm playing with the GPMC Com object.It's great that you can do so much with PowerShell, but the sheer inconsency of things lower down in the technology stack are infuriating. Sometimes things are case sensitive, other times not, some times you use quotes to hold names, other times not, etc - you probably know what I mean. This is not PowerShell's fault, but the result of a huge amount of parallel uncoordinated development within MS and therefore part of your learning curve.

The big advantage, however, of PowerShell is that you can do SO much all with one basic tool. And with a bit of work, you can write functions (and soon real cmdlets) in script that hide some of the nasty details.

PowerShell Rocks!!

Thursday, April 26, 2007

Still More on Longhorn B3 Download

Further to earlier posts, Longhorn B3 does appear to be on MSDN. After a reboot of Vista, I was able to finally get to the MSDN download site, to find Longhorn is available (and can be downloaded using the FTM download manager).

Interestingly - the download speeds from MSDN are around 600KBPS vs just under 200 from the TechNet site. And as mentioned earlier, downloading via Technet is a raw download - and mine aborted half way through!

Lonhorn downloaded in under an hour - now that rocks.

Friday, November 17, 2006

Vista RTM on MSDN, etc

It's early in the morning in Barcelona after yet another late night party at TechEd. While I slept, Microsoft flipped the switch and Vista RTM is on the MSDN site, as well as on the Connect site (for beta testers), and probably elsewhere.

Being the guy I am, I immediately hit MSDN and the DVD is being downloaded now. I'm in the hotel, using the 'b' wireless and I'm getting download speed in the region of 150-175 KB/Sec. Not shabby! I wonder just how much bandwidth and how many download servers MS has dedicated to this download?

So where's MOSS??

Technorati tags: ,