background preloader

MSDN

Facebook Twitter

Powershell Research - OpenFlags Enumeration (System.Security.Cryptography.X509Certificates) Specifies the way to open the X.509 certificate store. [FlagsAttribute] public enum OpenFlags The following code example opens an X.509 certificate store, adds and deletes certificates, and then closes the store. It assumes you have three certificates to add to and remove from a local store. .NET Framework Supported in: 4.5.1, 4.5, 4, 3.5, 3.0, 2.0 .NET Framework Client Profile Supported in: 4, 3.5 SP1 Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

Powershell Research - X509Store Class (System.Security.Cryptography.X509Certificates) Represents an X.509 store, which is a physical store where certificates are persisted and managed. This class cannot be inherited. System.ObjectSystem.Security.Cryptography.X509Certificates.X509Store public sealed class X509Store The X509Store type exposes the following members. Use this class to work with an X.509 store. This section contains two examples. The second example demonstrates how you can add and remove single certificates and ranges of certificates. Example 1 This example tries to open each standard store in each standard location on the current computer. Example 2 This example opens an X.509 certificate store, adds and deletes certificates, and then closes the store. .NET Framework Supported in: 4.5.1, 4.5, 4, 3.5, 3.0, 2.0 .NET Framework Client Profile Supported in: 4, 3.5 SP1 Any public static (Shared in Visual Basic) members of this type are thread safe.

Powershell Research - StoreName Enumeration (System.Security.Cryptography.X509Certificates) Specifies the name of the X.509 certificate store to open. This enumeration specifies the X.509 store name, which also includes the type of certificates included. For example, My includes personal certificates, whereas Disallowed includes only revoked certificates. The following code example opens an X.509 certificate store, adds and deletes certificates, and then closes the store. It assumes you have three certificates to add to and remove from a local store. .NET Framework Supported in: 4.5.1, 4.5, 4, 3.5, 3.0, 2.0 .NET Framework Client Profile Supported in: 4, 3.5 SP1 Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

Adding Custom Cmdlet Help for Providers - Windows PowerShell Blog. A new feature of Windows PowerShell 2.0 lets you write custom cmdlet help for Windows PowerShell providers. This blog explains how to do it. (The topic will also be covered in excruciating detail in MSDN, but we don't want you to wait.) What's a Provider? A Windows PowerShell provider is a C# program that exposes a data store to Windows PowerShell through a Windows PowerShell drive (PSDrive). When users view the PSDrive, the data in the data store appears to be organized like a file system drive. The drive has a path and users can navigate through the data store by using file system navigation commands like CD and DIR. For more information about designing a Windows PowerShell provider, see How to Create a Windows PowerShell Provider ( If you're a provider author (or the lucky writer), this feature is for you! Custom cmdlets? No, custom help topics for the provider cmdlets that your provider supports.

How do users get custom cmdlet help? New-Item -Plugin <string> Merry Christmas From PowerShell: The CodeDownloader Module - Windows PowerShell Blog. Twas the night before Christmas, and all through the net PowerShell lovers were wondering exactly what they might get Their readers were ready, their minds were aware That more joy of CTP3 would soon be there A cmdlet, a function? What has the PowerShell team done? How about a whole module, to share scripts with everyone? Some pluggable functions, to get code to share Scripts from Write-CommandBlogPost, from PoshCode, from Everywhere And what on the morning of Christmas did they see? But eight advanced functions, to get code from you or me. Get the Get-MarkupTag, Resolve-ShortcutFile, and Get-CommandPlugin from the earlier blog posts Download the zip file. Add some of the recent blog posts to your favorites, or some scripts from poshcode, and try using Import-ModuleFromWeb to import some scripts from the web into a module.

Import-ModuleFromWeb Detailed Description: Takes a base directory containing directories full of links to post. Here's Import-ModuleFromWeb: Import-CodeSnippet Get-Code. Get-CommandPlugin - Windows PowerShell Blog. One of the nifty new CTP3 features is command and parameter meta data on functions. In V1, you had to parse a function yourself to extract the parameters. In CTP2, you could use the tokenizer API to parse the function, but extracting parameters this was is error prone. In CTP3, and in V2, you can actually get a dictionary of parameters on the FunctionInfo object. Check it out: Get-Command -type Function | Foreach-Object { $_.Parameters } This opens up a lot of possibilities. One of the possibilities I really like is that you can now use the parameter metadata to determine if two functions fit together. One example of how you might want to use this is making a central script that runs all of your diagnostic scripts. Suppose I had several functions that worked against a remote machine: Get-InformationAboutProcessor -computer Get-InformationAboutFreeDiskSpace -computer Get-InformationAboutLocalUsers -computer etc etc etc This final possibility is both empowering and risky.

Synopsis: Examples of Host Application Code. In This Section This section includes the following topics. This example shows how to write a host application that invokes a command synchronously on the local computer. This example shows how to add cmdlets and their parameters to the command pipeline of a host application. After the command pipeline is complete, the host application invokes the pipeline synchronously on the local computer.

This example shows how to add a custom host to a host application. The following procedure highlights what is needed to specify a custom host implementation. This section includes examples that show how to invoke a pipeline synchronously or asynchronously. This section includes examples that show the different ways you can implement a custom host classes, including their related interfaces for supporting prompts for multiple choices and supporting interactive sessions. See Also. Writing a Windows PowerShell Cmdlet. Adding Parameters that Process Command-Line Input. The following sections are in this topic: Defining the Cmdlet Class [Cmdlet(VerbsCommon.Get, "proc")] public class GetProcCommand: Cmdlet Declaring Parameters A cmdlet parameter enables the user to provide input to the cmdlet.

PS> get-proc | get-member -membertype property To declare parameters for a cmdlet, you must first define the properties that represent the parameters. Here's the parameter declaration for the Name parameter of the Get-Proc cmdlet. /// <summary>/// Specify the cmdlet Name parameter./// </summary> [Parameter(Position = 0)] [ValidateNotNullOrEmpty] public string[] Name { get { return processNames; } set { processNames = value; } } private string[] processNames; #endregion Parameters This cmdlet uses an array of strings for the Name parameter. Things to Remember About Parameter Definitions Declaring Parameters as Positional or Named A cmdlet must set each parameter as either a positional or named parameter. Declaring Parameters as Mandatory or Optional Code Samples See Also. Cmdlet Development Guidelines. What is LightSwitch? LightSwitch Tutorials | Learn Lightswitch on MSDN.

F# Developer Center. Visual C# Tutorials and How Do I Learning Resources on MSDN. Visual C# Developer Center. "How Do I?" Videos for Visual C# Writing a Windows PowerShell Host Application. Using PowerShell to read xml-files - Little more than out of the box development. Background Jobs. Cmdlets can perform their action internally or as a Windows PowerShell background job. When a cmdlet runs as a background job, the work is done asynchronously in its own thread separate from the pipeline thread that the cmdlet is using. From the user perspective, when a cmdlet runs as a background job, the command prompt returns immediately even if the job takes an extended amount of time to complete, and the user can continue without interruption while the job runs. Background Jobs, Child Jobs, and the Job Repository The job object that is returned by the cmdlets that support background jobs defines the job. For more information about how background jobs are handled at the command line, see the following: Writing a Cmdlet That Runs as a Background Job To write a cmdlet that can be run as a background job, you must complete the following tasks: Background Job–Related APIs The following APIs are provided by Windows PowerShell to manage background jobs.

Derives custom job objects. Get-Job. Cmdlet Help Editor V2.0 with Module Support - Windows PowerShell Blog. Hi, I have updated the Cmdlet Help Editor tool to support Modules. The V1.0 version of this tool only supported PsSnapins. The original post can be found here Cmdlet Help Editor enables you to create help topics for Windows PowerShell cmdlets in the XML format that Windows PowerShell supports. Help text created in Cmdlet Help Editor can be displayed immediately by a Windows PowerShell get-help command without any additional transforms or formatting. By reflecting on a Windows PowerShell snap-in (PsSnapin) assembly or Module, Cmdlet Help Editor creates a customized documentation interface that includes the cmdlets, their parameters, and parameter attributes. Cmdlet Help Editor is designed for Windows PowerShell cmdlet developers to make it easy to create excellent cmdlet help.

You can download the tool from here: X64: X86: System Requirements Enjoy the tool, Wassim [MSFT] Improving Parameter Set Design - Windows PowerShell Blog. Designing useable cmdlets is part engineering and part art. It’s not an easy task to define the conceptual boundaries of a cmdlet (where does one cmdlet end and the next begin) or to provide great feature control without inundating the user with parameters. However, you can improve the usability of your cmdlets by avoiding two common parameter set design flaws. A parameter set with no mandatory parameters in a cmdlet that requires parameters Mandatory parameters with position numbers that are higher than the position numbers of optional parameters Parameter sets with no mandatory parameters Some cmdlets, like Get-Process, can be run without any parameters, so you'd expect them to have at least one parameter set with no mandatory parameters.

But look at the syntax of Get-WmiObject. But it's worse. Unless you can run the cmdlet without parameters, be sure that there is at least one mandatory parameter in each parameter set. Mandatory parameters with high position numbers. Improving Parameter Set Design - Windows PowerShell Blog. Designing Cmdlets That Have Lots of Parameters - Windows PowerShell Blog. We often get the question of what to do about a cmdlet that has lots of parameters. Do you break it up into multiple commands or just have a single cmdlet with lots of parameters. Here is the way I think about it: If you have to enter 100 things to get a job done, it doesn’t really matter whether you enter those 100 things via 1 cmdlet with 100 parameters or 10 cmdlets with 10 parameters each. If anything, there are a number of good reasons to have 1 cmdlet with 100 parameters including the fact that you don’t have to enter 10 cmdlets and you produce an abstraction which is much more friendly to being exposed as a REST API.

Let me be quick to point out the trick – that is all about if you have to enter 100 things to do something. PS> Get-Help New-PSSession -Parameter SessionOption -SessionOption <PSSessionOption> Sets advanced options for the session. The default values for the options are determined by the value of the $PSSe ssionOption preference variable, if it is set.

Required? PowerShell PowerBook. Description PowerBook is the Facebook Module for Windows PowerShell. PowerBook allows you to use many of Facebook features and interact with Facebook via Windows PowerShell. PowerBook contain 24 PowerShell functions that allow you to do most of Facebook actions. PowerBook is the result of integration between Windows PowerShell and Facebook Developer’s Toolkit v3.0. The story behind PowerShell PowerBook Since I’m a big fan of Windows PowerShell and one of Windows PowerShell MVPs, I’m always thinking about how to widely publicize it? I found that the best way is doing something shows PowerShell features via something that used by a large number of computer users. I found that Facebook social network is the best and easy way to reach large number of users with different computer cultures; IT Professionals, Developers, and normal user with little computer background.

Note: Since it’s the first try of using Facebook Developer Toolkit, you may face some of unhandled or unexpected errors. 1. 2.