Introduction
The xPSDesiredStateConfiguration module is a part of the Windows PowerShell Desired State Configuration (DSC) Resource Kit, which is a collection of DSC Resources produced by the PowerShell Team. This module contains the
xDscWebService , xWindowsProcess, xService, xPackage, xRemoteFile, and xGroup resources, and
xFileUpload composite resource. Please see the Details section for more information on the functionalities provided by these resources.
All of the resources in the DSC Resource Kit are provided AS IS, and are not supported through any Microsoft standard support program or service. The "x" in xPSDesiredStateConfiguration stands for experimental, which means that these resources
will be fix forward and monitored by the module owner(s).
Please leave comments, feature requests, and bug reports in the Q & A tab for this module.
If you would like to modify xPSDesiredStateConfiguration module, feel free. When modifying, please update the module name, resource friendly name, and MOF class name (instructions below). As specified in the license, you may copy or modify
this resource as long as they are used on the Windows Platform.
For more information about Windows PowerShell Desired State Configuration, check out the blog posts on the
PowerShell Blog (this
is a good starting point). There are also great community resources, such as
PowerShell.org
, or
PowerShell Magazine
. For more information on the DSC Resource Kit, check out
this blog post.
Installation
To install xPSDesiredStateConfiguration module
- Unzip the content under $env:ProgramFiles\WindowsPowerShell\Modules folder
To confirm installation:
-
Run Get-DSCResource to see that xDscWebService , xWindowsProcess, xService, xRemoteFile, xPackage, xGroup and xFileUpload are among the DSC Resources listed
Requirements
This module requires the latest version of PowerShell (v4.0, which ships in Windows 8.1 or Windows Server 2012R2). To easily use PowerShell 4.0 on older operating systems,
install WMF 4.0. Please read the installation instructions that are present on both the download page and the release notes for WMF 4.0.
Description
The xPSDesiredStateConfiguration module contains the
xDscWebService , xWindowsProcess, xService, xPackage, xRemoteFile, xGroup, and xFileUpload
DSC Resources. The xDscWebService resource allows the configuration of a OData endpoint for DSC Service to make a node a DSC Pull Server. The xWindowsProcess resource
is an enhancement to the inbox WindowsProcess resource and allows you to run a process under the context of a user. (Note that the user needs to log in at least once so that his profile is present on the system.) The xService resource is also an enhancement
on the inbox and allows you to create and delete a service . xRemoteFile allows to download file from HTTP or HTTPS location to local destination. It provides possibility to specify user agent and headers when sending a web request. xFileUpload is a composite
resource which allows to upload file from local machine to the SMB share. xPackage resource allows installation of .msi and .exe software installations. xGroup extends the in-box Group resource with support for cross-domain account resolution and UPN names.
Details
xDscWebService resource has following properties:
-
EndpointName: The desired web service name
-
CertificateThumbPrint: Certificate thumbprint for creating HTTPS endpoint
-
Port: Port
for web service
-
PhysicalPath: Folder location where content of web service resides
-
State: State
of the web service - Started or Stopped
-
ModulePath: Folder location where DSC Resources are stored
-
ConfiguraitonPath: Folder location where DSC Configurations are stored
-
IsComplianceServer: Should the web service endpoint expose compliance data
-
Ensure: Should
the web service be created or deleted
Some of the properties of the xWindowsProcess resource are enumerate below. For a complete list, please use Get-DscResource
-
Path: The full path or the process executable
-
Arguments: This is a mandatory parameter for passing in arguments to the process executable. Specify an empty string if you don't want to pass any arguments
-
Credential: The credentials of the user under who's context you want to run the process.
-
Ensure: An enumeration stating if the process needs to be running or stopped
Some of the properties of the xService resource are enumerate below. For a complete list, please use Get-DscResource
-
Name: The name for the service
-
Ensure: An enumeration which stating whether the service needs to be created (when set to 'Present') or deleted (when set to 'Absent')
-
Path: The path to the service executable file. This is a requied parameter if Ensure is set to true
xRemoteFile resource has following properties:
-
DestinationPath:Path under which downloaded file should be accessible after operation
-
Uri:Uri of a file which should be downloaded
-
UserAgent:User agent for the web request
-
Headers:Headers of the web request
-
Credential:Specifies credential of a user which has permissions to send the request
-
Ensure:Says whether DestinationPath exists on the machine
xFileUpload resource has following properties:
-
DestinationPath:Path under which file should be accessible after uploading
-
SourcePath:Path to the file which should be uploaded
-
Credential:PSCredential object with to access DestinationPath. Username in domain\user format.
-
CertificateThumbprint:Thumbprint of the certificate which should be used for encryption/decryption
The properties of the xPackage resource are enumerated below. For a complete list, please use Get-DscResource
-
Ensure:
An enumeration which stating whether the service needs to be created (when set to 'Present') or deleted (when set to 'Absent')
-
Name:
The
name of the package.
-
Path:
The source path for the package.
-
ProductId:
The product id of the package. Usually
a GUID value.
-
Arguments:
Command line arguments passed on the installation
command line.
-
Credential: Credentials necessary to access the Path.
-
ReturnCode:
An array of return codes that are returned after a successful
installation.
-
LogPath:
The destination
path of the log.
-
PackageDescription: A text description of the package being installed.
-
Publisher: Publisher's name.
-
InstalledOn: Date of installation.
-
Size:
Size of the installation.
-
Version:
Version
of the package.
-
Installed:
Is the package
installed?
-
RunAsCredential: Credentials to run under when installing the package.
-
InstalledCheckRegKey: Registry key to open to check for package installation status.
-
InstalledCheckRegValueName: Registry value name to check for package installation status.
-
InstalledCheckRegValueData: Value to compare against the retrieved value to check for package installation.
The xGroup resource extends the in-box Group resource by supporting cross-domain account lookup where a valid trust relationship exists.
In addition, limited support for UPN-formatted names are supported for identifying user, computer, and group domain-based accounts. The properties of the xGroup
resource are identical to the in-box resource and include the following:
-
GroupName: The name of the group for which you want to ensure a specific state
-
Ensure: An enumeration stating if the group should be Present (default)or Absent.
-
Description: Description of the group.
-
Members: The members that form the group.
-
Important ......................If the group already exists, the listed items in this property replaces what is in the Group.
-
MembersToInclude: List of users to add to the group.
-
Important ......................This property is ignored if 'Members' is specified.
-
MembersToExclude: List of users you want to ensure are not members of the group.
-
Important ......................This property is ignored if 'Members' is specified.
-
Credential: Indicates the credentials required to access remote resources.
-
Important ......................This account must have the appropriate Active Directory permissions to add all non-local accounts to the group; otherwise, an error will occur.
Local accounts may be specified in one of the following ways:
- The simple name of the account of the group or local user.
- The account name scoped to the explicit machine name; such as myserver\users or myserver\username
- The account name scoped using the explicit local machine qualifier; such as .\users or .\username
Domain members may be specified using domain\name or Universal Principal Name (UPN) formatting. The following illustrates the various formats
- Domain joined machines: mydomain\myserver or myserver@mydomain.com
- Domain user accounts: mydomain\username or username@mydomain.com
- Domain group accounts: mydomain\groupname or groupname@mydomain.com
Renaming Requirements
When making changes to these resources, we suggest the following practice:
-
Update the following names by replacing MSFT with your company/community name and replacing the
"x" with "c" (short for "Community") or another prefix of your choice:
-
Module name (ex: xPSDesiredStateConfiguration becomes
cPSDesiredStateConfiguration
)
-
Resource folder (ex: MSFT_DscWebService becomes Contoso_cDscWebService)
-
Resource Name (ex: MSFT_DscWebService becomes Contoso_cDscWebService)
-
Resource Friendly Name (ex: DscWebService becomes cDscWebService)
-
MOF class name (ex: MSFT_DscWebService becomes Contoso_cDscWebService)
-
Filename for the <resource>.schema.mof (ex: MSFT_DscWebService.schema.mof becomes
Contoso_cDscWebService.schema.mof)
- Update module and metadata information in the module manifest
- Update any configuration that use these resources
We reserve resource and module names without prefixes ("x" or "c") for future use (e.g. "MSFT_DscWebService" or "DscWebService"). If the next version of Windows Server ships with a "DscWebService" resource, we don't want to break any configurations that
use any community modifications. Please keep a prefix such as "c" on all community modifications.
Versions
3.0.2.0
-
Adding following resources:
3.0.1.0
-
Adding following resources:
2.0.0.0
-
Adding following resources:
- xWindowsProcess
- xService
- xRemoteFile
- xPackage
1.1.0.0
-
Fix to remove and recreate the SSL bindings when performing a new HTTPS IIS Endpoint setup
- Fix in the resource module to consume WebSite Name parameter correctly
1.0.0.0
-
Initial release with the following resources
Example: Change the Name and the Workgroup Name
This configuration will set a machine name and changes the workgroup it is in.
Example: Switch from a Workgroup to a Domain
This configuration sets the machine name and joins a domain.
Note: this requires a credential.
Example: Change the Name while staying on the Domain
This example will change the machines name while remaining on the domain.
Note: this requires a credential.
Example: Change the Name while staying on the Workgroup
This example will change the machines name while remaining on the workgroup.
Example: Switch from a Domain to a Workgroup
This example switches the computer from a domain to a workgroup.
Note: this requires a credential.
Example: Download file from uri. Specify headers and user agent.
This configuration will download file from specific uri to DestinationPath. Web request will contain specific headers and will be sent as a specified user agent.
Example: Upload file to SMB share.
This configuration will upload file from SourcePath to the remote DestinationPath. Username and password will be used to access the DestinationPath
Example: Sample1.ps1 installs a package that uses an .exe file.
This configuration will install a the .exe package verifying the package using the package name.
Example: Sample1.ps2 installs a package that uses an .exe file.
This configuration will install a the .exe package and verify the package using the product id and package name .
Example: Sample1.ps3 installs a package that uses an .msi file.
This configuration will install a the .msi package and verify the package using the product id and package name and requires credentials to read the share and install the package.
Example: Sample1.ps4 installs a package that uses an .exe file.
This configuration will install a the .exe package and verify the package using the product id and package name and requires credentials to read the share and install the package. It also uses custom registry values to check for the package presence.