Thursday, June 4, 2015

PowerShell 5.0 - what's new for the DSC guy - part 3

WMF 5.0 now supports help for DSC configurations. You can create help contents along with your configuration and distribute it. The get-help cmdlet can now show the contents from the help description from the configuration file. You can combine the cmdlet with options like –Full, -Detailed etc. to see different options like SYNOPISIS, DESCRIPTION, PARAMETERs, EXAMPLEs etc.
The help support is currently only available for configurations copied to folder mentioned in the PATH variable. Let’s start by creating help for the configuration for the xSPManagedAccount resource sample created in the part 1 post of this series.
<#
.SYNOPSIS

The configuration when applied registers a new managed account. This configuration adds a new managed account to the farm by using credentials that are provided
.DESCRIPTION

The configuration uses the xSPManagedAccount DSC resource to create a managed account in the farm.


.PARAMETER Username : The username of the account
.PARAMETER Password : The password of the account
.PARAMETER Ensure : Ensures the account should be present or absent in the farm


.EXAMPLE
Import-Dscresource -ModuleName xSPManagedAccount   
  
xSPManagedAccount ManagedAccount
{
    Username = "Domain\MYUserName"
    Password = "MySecretPassword"
    Ensure = "Present"       
}
#>

Configuration SPManagedAccountConfig
{
    Import-Dscresource -ModuleName xSPManagedAccount   
  
    xSPManagedAccount ManagedAccount
    {
        Username = "Domain\MYUserName"
        Password = "MySecretPassword"
        Ensure = "Present"       
    }      
}

SPManagedAccountConfig 

To see the help you can use multiple options like
PS C:\wmf5> SPManageAccountConfig -?

NAME
    C:\Windows\system32\SPManageAccountConfig.ps1
   
SYNOPSIS
    The configuration when applied registers a new managed account. This configuration adds a new managed account to the farm by using credentials that are provided
   
   
SYNTAX
    C:\Windows\system32\SPManageAccountConfig.ps1 []
   
   
DESCRIPTION
    The configuration uses the xSPManagedAccount DSC resource to create a managed account in the farm.
   

RELATED LINKS

REMARKS
    To see the examples, type: "get-help C:\Windows\system32\SPManageAccountConfig.ps1 -examples".
    For more information, type: "get-help C:\Windows\system32\SPManageAccountConfig.ps1 -detailed".
    For technical information, type: "get-help C:\Windows\system32\SPManageAccountConfig.ps1 -full".

PS C:\windows\system32> get-help spmanagedaccountconfig -full

NAME
    SPManagedAccountConfig
   
SYNTAX
    SPManagedAccountConfig [[-InstanceName] ] [[-DependsOn] ] [[-OutputPath] ] [[-ConfigurationData]
   
   
PARAMETERS
    -ConfigurationData
       
        Required?                    false
        Position?                    3
        Accept pipeline input?       false
        Parameter set name           (All)
        Aliases                      None
        Dynamic?                     false
       
    -DependsOn
       
        Required?                    false
        Position?                    1
        Accept pipeline input?       false
        Parameter set name           (All)
        Aliases                      None
        Dynamic?                     false
        
    -InstanceName
       
        Required?                    false
        Position?                    0
        Accept pipeline input?       false
        Parameter set name           (All)
        Aliases                      None
        Dynamic?                     false
       
    -OutputPath
       
        Required?                    false
        Position?                    2
        Accept pipeline input?       false
        Parameter set name           (All)
        Aliases                      None
        Dynamic?                     false
       
   
INPUTS
    None
   
   
OUTPUTS
    System.Object
   
ALIASES
    None
   

REMARKS
    None

PS C:\windows\system32> get-help spmanagedaccountconfig -detailed

NAME
    SPManagedAccountConfig
   
SYNTAX
    SPManagedAccountConfig [[-InstanceName] ] [[-DependsOn] ] [[-OutputPath] ] [[-ConfigurationData]
   
   
PARAMETERS
    -ConfigurationData
   
    -DependsOn
   
    -InstanceName
   
    -OutputPath
   

ALIASES
    None
   

REMARKS
    None


No comments: