Skip to content

Commit

Permalink
Merge pull request #245 from mbreakey3/xUserChanges
Browse files Browse the repository at this point in the history
updating changes to xUser
  • Loading branch information
mbreakey3 authored Oct 7, 2016
2 parents ef94a78 + 6dac6b4 commit a87c3b2
Show file tree
Hide file tree
Showing 11 changed files with 1,417 additions and 602 deletions.
900 changes: 543 additions & 357 deletions DSCResources/MSFT_xUserResource/MSFT_xUserResource.psm1

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions DSCResources/MSFT_xUserResource/MSFT_xUserResource.schema.mof
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[ClassVersion("1.0.0"), FriendlyName("xUser")]
class MSFT_xUserResource : OMI_BaseResource
{
[Key] string UserName;
[write,ValueMap{"Present", "Absent"},Values{"Present", "Absent"}] string Ensure;
[write] string FullName;
[write] string Description;
[write,EmbeddedInstance("MSFT_Credential")] string Password;
[write] boolean Disabled;
[write] boolean PasswordNeverExpires;
[write] boolean PasswordChangeRequired;
[write] boolean PasswordChangeNotAllowed;
[Key,Description("The name of the User to Create/Modify/Delete")] String UserName;
[Write,Description("An enumerated value that describes if the user is expected to exist on the machine"),ValueMap{"Present", "Absent"},Values{"Present", "Absent"}] String Ensure;
[Write,Description("The display name of the user")] String FullName;
[Write,Description("A description for the user")] String Description;
[Write,Description("The password for the user"),EmbeddedInstance("MSFT_Credential")] String Password;
[Write,Description("Value used to disable/enable a user account")] Boolean Disabled;
[Write,Description("Value used to set whether a user's password expires or not")] Boolean PasswordNeverExpires;
[Write,Description("Value used to require a user to change their password")] Boolean PasswordChangeRequired;
[Write,Description("Value used to set whether a user can/cannot change their password")] Boolean PasswordChangeNotAllowed;
};
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
# Localized resources for MSFT_xUserResource
# Localized resources for xUser

ConvertFrom-StringData @'
###PSLOC
UserWithName=User: {0}
RemoveOperation=Remove
AddOperation=Add
SetOperation=Set
ConfigurationStarted=Configuration of user {0} started.
ConfigurationCompleted=Configuration of user {0} completed successfully.
UserCreated=User {0} created successfully.
UserUpdated=User {0} properties updated successfully.
UserRemoved=User {0} removed successfully.
NoConfigurationRequired=User {0} exists on this node with the desired properties. No action required.
NoConfigurationRequiredUserDoesNotExist=User {0} does not exist on this node. No action required.
InvalidUserName=The name {0} cannot be used. Names may not consist entirely of periods and/or spaces, or contain these characters: {1}
UserExists=A user with the name {0} exists.
UserDoesNotExist=A user with the name {0} does not exist.
PropertyMismatch=The value of the {0} property is expected to be {1} but it is {2}.
PasswordPropertyMismatch=The value of the {0} property does not match.
AllUserPropertisMatch=All {0} {1} properties match.
ConnectionError = There could be a possible connection error while trying to use the System.DirectoryServices API's.
MultipleMatches = There could be a possible multiple matches exception while trying to use the System.DirectoryServices API's.
###PSLOC
UserWithName = User: {0}
RemoveOperation = Remove
AddOperation = Add
SetOperation = Set
ConfigurationStarted = Configuration of user {0} started.
ConfigurationCompleted = Configuration of user {0} completed successfully.
UserCreated = User {0} created successfully.
UserUpdated = User {0} properties updated successfully.
UserRemoved = User {0} removed successfully.
NoConfigurationRequired = User {0} exists on this node with the desired properties. No action required.
NoConfigurationRequiredUserDoesNotExist = User {0} does not exist on this node. No action required.
InvalidUserName = The name {0} cannot be used. Names may not consist entirely of periods and/or spaces, or contain these characters: {1}
UserExists = A user with the name {0} exists.
UserDoesNotExist = A user with the name {0} does not exist.
PropertyMismatch = The value of the {0} property is expected to be {1} but it is {2}.
PasswordPropertyMismatch = The value of the {0} property does not match.
AllUserPropertisMatch = All {0} {1} properties match.
ConnectionError = There could be a possible connection error while trying to use the System.DirectoryServices API's.
MultipleMatches = There could be a possible multiple matches exception while trying to use the System.DirectoryServices API's.
'@
File renamed without changes.
68 changes: 68 additions & 0 deletions Examples/Sample_xUser_Generic.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
param
(
[Parameter(Mandatory)]
[System.String]
$ConfigurationName
)

<#
Create a custom configuration by passing in whatever
values you need. $Password is the only param that is
required since it must be a PSCredential object.
If you want to create a user with minimal attributes,
every param except username can be deleted since they
are optional.
#>

Configuration $ConfigurationName
{
param
(
[System.String]
$UserName = 'Test UserName',

[System.String]
$Description = 'Test Description',

[System.String]
$FullName = 'Test Full Name',

[ValidateSet('Present', 'Absent')]
[System.String]
$Ensure = 'Present',

[Parameter(Mandatory)]
[System.Management.Automation.PSCredential]
$Password,

[System.Boolean]
$Disabled = $false,

[System.Boolean]
$PasswordNeverExpires = $false,

[System.Boolean]
$PasswordChangeRequired = $false,

[System.Boolean]
$PasswordChangeNotAllowed = $false
)

Import-DscResource -ModuleName 'xPSDesiredStateConfiguration'

Node Localhost {

xUser UserResource1
{
UserName = $UserName
Ensure = $Ensure
FullName = $FullName
Description = $Description
Password = $Password
Disabled = $Disabled
PasswordNeverExpires = $PasswordNeverExpires
PasswordChangeRequired = $PasswordChangeRequired
PasswordChangeNotAllowed = $PasswordChangeNotAllowed
}
}
}
38 changes: 27 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@ Please check out common DSC Resources [contributing guidelines](https://github.c
* **xGroupSet** configures multiple xGroups with common settings but different names.
* **xProcessSet** allows starting and stopping of a group of windows processes with no arguments.
* **xServiceSet** allows starting, stopping and change in state or account type for a group of services.
* **xUser** provides a mechanism to manage local users on the target node.
* **xWindowsFeatureSet** allows installation and uninstallation of a group of Windows features and their subfeatures.
* **xWindowsOptionalFeature** provides a mechanism to enable or disable optional features on a target node.
* **xWindowsOptionalFeatureSet** allows installation and uninstallation of a group of optional Windows features.

Resources that work on Nano Server:

* xWindowsOptionalFeature
* xUser

### xArchive

Expand Down Expand Up @@ -212,25 +214,37 @@ xRegistry provides a mechanism to manage registry keys and values on a target no
* **Credential**: Indicates the credentials to use for running this script, if credentials are required.

### xUser
* **UserName**: Indicates the account name for which you want to ensure a specific state.
* **Description**: Indicates the description you want to use for the user account.
* **Disabled**: Indicates if the account is enabled. Set this property to $true to ensure that this account is disabled, and set it to $false to ensure that it is enabled.
Provides a mechanism to manage local users on a target node.

#### Requirements

* Target machine must be running a windows client operating system, Windows Server 2012 or later, or Nano Server.

#### Parameters

* **[String] UserName** _(Key)_: Indicates the account name for which you want to ensure a specific state.
* **[String] Description** _(Write)_: Indicates the description you want to use for the user account.
* **[Boolean] Disabled** _(Write)_: Indicates if the account is enabled. Set this property to $true to ensure that this account is disabled, and set it to $false to ensure that it is enabled.
- Suported values: $true, $false
- Default value: $false
* **Ensure**: Ensures that the feature is present or absent.
* **[String] Ensure** _(Write)_: Ensures that the feature is present or absent.
- Supported values: Present, Absent
- Default Value: Present
* **FullName**: Represents a string with the full name you want to use for the user account.
* **Password**: Indicates the password you want to use for this account.
* **PasswordChangeNotAllowed**: Indicates if the user can change the password. Set this property to $true to ensure that the user cannot change the password, and set it to $false to allow the user to change the password.
* **[String] FullName** _(Write)_: Represents a string with the full name you want to use for the user account.
* **[PSCredential] Password** _(Write)_: Indicates the password you want to use for this account.
* **[Boolean] PasswordChangeNotAllowed** _(Write)_: Indicates if the user can change the password. Set this property to $true to ensure that the user cannot change the password, and set it to $false to allow the user to change the password.
- Suported values: $true, $false
- Default value: $false
* **PasswordChangeRequired**: Indicates if the user must change the password at the next sign in. Set this property to $true if the user must change the password.
* **[Boolean] PasswordChangeRequired** _(Write)_: Indicates if the user must change the password at the next sign in. Set this property to $true if the user must change the password.
- Suported values: $true, $false
- Default value: $true
* **PasswordNeverExpires**: Indicates if the password will expire. To ensure that the password for this account will never expire, set this property to $true, and set it to $false if the password will expire.
* **[Boolean] PasswordNeverExpires** _(Write)_: Indicates if the password will expire. To ensure that the password for this account will never expire, set this property to $true, and set it to $false if the password will expire.
- Suported values: $true, $false
- Default value: $false

#### Examples

* [Create a new User](https://github.com/PowerShell/xPSDesiredStateConfiguration/blob/dev/Examples/Sample_xUser_CreateUser.ps1)

### xGroupSet
* **GroupName**: Defines the names of the groups in the set.
Expand Down Expand Up @@ -365,8 +379,10 @@ These parameters will be the same for each Windows optional feature in the set.
* Formatting updated as per style guidelines
* Missing comment-based help added for Get-/Set-/Test-TargetResource
* Typos fixed in Unit test script
* Unit test 'Get-TargetResource/Should return hashtable with correct values when group
has no members' updated to handle the expected empty Members array correctly
* Unit test 'Get-TargetResource/Should return hashtable with correct values when group has no members' updated to handle the expected empty Members array correctly
* xUser:
* Fixed PSSA/Style violations
* Added/Updated Tests and Examples

### 4.0.0.0

Expand Down
Loading

0 comments on commit a87c3b2

Please sign in to comment.