GithubHelp home page GithubHelp logo

psdscresources's Introduction

logo PowerShell

Welcome to the PowerShell GitHub Community! PowerShell is a cross-platform (Windows, Linux, and macOS) automation and configuration tool/framework that works well with your existing tools and is optimized for dealing with structured data (e.g. JSON, CSV, XML, etc.), REST APIs, and object models. It includes a command-line shell, an associated scripting language, and a framework for processing cmdlets.

Windows PowerShell vs. PowerShell Core

Although this repository started as a fork of the Windows PowerShell codebase, changes made in this repository are not automatically ported back to Windows PowerShell 5.1. This also means that issues tracked here are only for PowerShell Core 6 and higher. Windows PowerShell specific issues should be reported with the Feedback Hub app, by choosing "Apps > PowerShell" in the category.

New to PowerShell?

If you are new to PowerShell and want to learn more, we recommend reviewing the getting started documentation.

Get PowerShell

You can download and install a PowerShell package for any of the following platforms.

Supported Platform Download (LTS) Downloads (stable) Downloads (preview) How to Install
Windows (x64) .msi .msi .msi Instructions
Windows (x86) .msi .msi .msi Instructions
Ubuntu 22.04 .deb .deb .deb Instructions
Ubuntu 20.04 .deb .deb .deb Instructions
Ubuntu 18.04 .deb .deb .deb Instructions
Ubuntu 16.04 .deb N/A N/A Instructions
Debian 10 .deb .deb .deb Instructions
Debian 11 .deb .deb .deb
CentOS 7 .rpm .rpm .rpm Instructions
CentOS 8 .rpm .rpm .rpm
Red Hat Enterprise Linux 7 .rpm .rpm .rpm Instructions
openSUSE 42.3 .rpm .rpm .rpm Instructions
Fedora 35 .rpm .rpm .rpm Instructions
macOS 10.13+ (x64) .pkg .pkg .pkg Instructions
macOS 11+ (arm64) .pkg .pkg .pkg Instructions
Docker Instructions

You can download and install a PowerShell package for any of the following platforms, which are supported by the community.

Platform Downloads (stable) Downloads (preview) How to Install
Arch Linux Instructions
Kali Linux .deb .deb Instructions
Many Linux distributions Snapcraft Snapcraft

You can also download the PowerShell binary archives for Windows, macOS, and Linux.

Platform Downloads (stable) Downloads (preview) How to Install
Windows 32-bit/64-bit 32-bit/64-bit Instructions
macOS (x64) 64-bit 64-bit Instructions
macOS (arm64) 64-bit 64-bit Instructions
Linux 64-bit 64-bit Instructions
Windows (ARM) 64-bit (preview) 64-bit Instructions
Raspbian (ARM) 32-bit/64-bit 32-bit/64-bit Instructions

To install a specific version, visit releases.

Upgrading PowerShell

For best results when upgrading, you should use the same install method you used when you first installed PowerShell. The update method will be different for each platform and install method. For more information, see Installing PowerShell.

Community Dashboard

Dashboard with visualizations for community contributions and project status using PowerShell, Azure, and PowerBI.

For more information on how and why we built this dashboard, check out this blog post.

Discussions

GitHub Discussions is a feature to enable free and open discussions within the community for topics that are not related to code, unlike issues.

This is an experiment we are trying in our repositories, to see if it helps move discussions out of issues so that issues remain actionable by the team or members of the community. There should be no expectation that PowerShell team members are regular participants in these discussions. Individual PowerShell team members may choose to participate in discussions, but the expectation is that community members help drive discussions so that team members can focus on issues.

Create or join a discussion.

Chat

Want to chat with other members of the PowerShell community?

There are dozens of topic-specific channels on our community-driven PowerShell Virtual User Group, which you can join on:

Add-ons and libraries

Awesome PowerShell has a great curated list of add-ons and resources.

Building the Repository

Linux Windows macOS
Instructions Instructions Instructions

If you have any problems building, consult the developer FAQ.

Build status of nightly builds

Azure CI (Windows) Azure CI (Linux) Azure CI (macOS) CodeFactor Grade
windows-nightly-image linux-nightly-image macOS-nightly-image cf-image

Downloading the Source Code

You can clone the repository:

git clone https://github.com/PowerShell/PowerShell.git

For more information, see working with the PowerShell repository.

Developing and Contributing

Please look into the Contribution Guide to know how to develop and contribute. If you are developing .NET Core C# applications targeting PowerShell Core, check out our FAQ to learn more about the PowerShell SDK NuGet package.

Also, make sure to check out our PowerShell-RFC repository for request-for-comments (RFC) documents to submit and give comments on proposed and future designs.

Support

For support, see the Support Section.

Legal and Licensing

PowerShell is licensed under the MIT license.

Windows Docker Files and Images

License: By requesting and using the Container OS Image for Windows containers, you acknowledge, understand, and consent to the Supplemental License Terms available on Docker Hub:

Telemetry

Please visit our about_Telemetry topic to read details about telemetry gathered by PowerShell.

Governance

The governance policy for the PowerShell project is described here.

This project has adopted the Microsoft Open Source Code of Conduct. For more information, see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

psdscresources's People

Contributors

andreassobczyk avatar avkaur avatar corydwood avatar duracellko avatar johlju avatar kevinobee avatar kwirkykat avatar mbreakey3 avatar mgreenegit avatar mhendric avatar nanalakshmanan avatar narrieta avatar plagueho avatar timhaintz avatar travisez13 avatar x-guardian avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

psdscresources's Issues

TestScript is not returning the expected data

Hi,
I am using Script to run sn.ps1 only if the mentioned key below does not exist . In the first run, machine will not have this and expected sn.ps1 to run. Somehow it is not running. I am wondering if the logic in TestScript block is valid ? Appreciate your inputs.

Script RunSnbat
{

        GetScript =
        {
            # Do Nothing 

            $strongName = "hklm:\SOFTWARE\Microsoft\StrongName\Verification" 
            $IsStrongNameExists = Test-Path $strongName  
                       
        }

        SetScript = 
        {
            
            $runSnbat =  C:\SXS\sn.ps1 
         
        }

        TestScript = 
        {
    
          
            $IsExists = $GetScript
            if ($IsExists) {return $true} else {return $false}
        }          

   } 

Group resource Exception when Groupname is 'Users'

Not sure what the problem is. Only occurrs for the Users group.

Configuration DscAddGroup {
  Import-DscResource -ModuleName 'PSDscResources'

  Node 'localhost' {
    Group Users {
      GroupName = 'Users'
    }
  }
}

DscAddGroup
Test-DscConfiguration -Path .\DscAddGroup

yields

PowerShell DSC resource MSFT_GroupResource  failed to execute Test-TargetResource functionality with error message: Exception calling
".ctor" with "2" argument(s): "Server names cannot contain a space character."
    + CategoryInfo          : InvalidOperation: (root/Microsoft/...gurationManager:String) [], CimException
    + FullyQualifiedErrorId : ProviderOperationExecutionFailure
    + PSComputerName        : localhost

If the name of the group is changed to any other existing or non-existing group all works ok.
Tested on a fresh Windows 10 installation.
Using 'PSDesiredStateConfiguration' instead the error is the same though somewhat more verbose:

Exception calling ".ctor" with "2" argument(s): "Server names cannot contain a space character."
    + CategoryInfo          : InvalidOperation: (:) [], CimException
    + FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand
    + PSComputerName        : localhost

The PowerShell DSC resource '[Group]Users' with SourceInfo 'C:\Users\admin\Desktop\TestConfig.ps1::5::5::Group' threw one or more
non-terminating errors while running the Test-TargetResource functionality. These errors are logged to the ETW channel called
Microsoft-Windows-DSC/Operational. Refer to this channel for more details.
    + CategoryInfo          : InvalidOperation: (root/Microsoft/...gurationManager:String) [], CimException
    + FullyQualifiedErrorId : NonTerminatingErrorFromProvider
    + PSComputerName        : localhost

Replacement for xRemoteFile resource

Hi,

Updating a bunch of DSC configurations to remove experimental modules etc. What is the replacement (if any) for xRemoteFile from xPSDesiredStateConfiguration?

I thought I could use the File resource with the source being a URL but reading comments this doesn't seem to be the case.

Avoid using the Win32_Product WMI class

This repository has reference to Win32_Product WMI class. As reported in issue PowerShell/DscResources#108, if possible then avoid using the Win32_Product.

If you are using a group policy with the WMIFilter that queries Win32_Product, modify the filter to use Win32reg_AddRemovePrograms
...
Win32reg_AddRemovePrograms is a much lighter and effective way to do this, which avoids the calls to do a resiliency check, especially in a locked down environment. So when using Win32reg_AddRemovePrograms we will not be calling on msiprov.dll and will not be initiating a resiliency check.
https://support.microsoft.com/en-us/kb/974524

There might not be possible to avoid using it, but for someone to determine that an issue is opened in very repository that has a reference to Win32_Product WMI class.

One-two of the Process tests fail intermittently due to log file issues

There seems to be a timing issue with log file creation in the Process tests.
Re-triggering the build fixes it sometimes, but it's really annoying.

Sometimes only the first test fails and the second is fine.

Here's the error from AppVeyor:
Context Should start a new testProcess instance as running [+] Should not have a logfile already present 52ms The 'Microsoft.PowerShell.Management' module was not imported because the 'Microsoft.PowerShell.Management' snap-in was already imported. [+] Should compile without throwing 433ms [+] Should be able to call Get-DscConfiguration without throwing 122ms [+] Should return the correct configuration 145ms [-] Should create a logfile 77ms Expected: {True} But was: {False} at <ScriptBlock>, C:\projects\psdscresources\Tests\Integration\MSFT_WindowsProcess.Integration.Tests.ps1: line 114 114: $pathResult | Should Be $true Context Should not start a second new testProcess instance when one is already running [-] Should have a logfile already present 77ms Expected: {True} But was: {False} at <ScriptBlock>, C:\projects\psdscresources\Tests\Integration\MSFT_WindowsProcess.Integration.Tests.ps1: line 124 124: $pathResult | Should Be $true [-] Should not throw when removing the log file 42ms Expected: the expression not to throw an exception. Message was {Cannot find path 'C:\projects\psdscresources\Tests\TestHelpers\processTestLog.txt' because it does not exist.} from C:\projects\psdscresources\Tests\Integration\MSFT_WindowsProcess.Integration.Tests.ps1:128 char:19 + { Remove-Item -Path $logFilePath } | Should not Throw + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ at <ScriptBlock>, C:\projects\psdscresources\Tests\Integration\MSFT_WindowsProcess.Integration.Tests.ps1: line 128 128: { Remove-Item -Path $logFilePath } | Should not Throw The 'Microsoft.PowerShell.Management' module was not imported because the 'Microsoft.PowerShell.Management' snap-in was already imported. [+] Should compile without throwing 362ms [+] Should be able to call Get-DscConfiguration without throwing 122ms [+] Should return the correct configuration 168ms [+] Should not create a logfile 25ms

Service: Can the DSC User Resource change existing user account passwords?

Situation
Lets say I updated a partial to have user account X use and new password Y. This user and password already exists on the target node, And there existing services running with user X's credentials.
Can DSC update the password of user X when I push the mof ?

Issues
When I tried to do this, I have gotten password incorrect errors when i execute Start-DSCConfiguration and the services using the changed user account stop running.

System Information
OS Name: Microsoft Windows Server 2012 R2 Standard
Version 6.3.9600 Build 9600

Can't import a specific resource

I am finding this module challenging to use since there are naming conflicts with PSDesiredStateconfiguration. But for now I am trying to use this in a DSC Configuration

Import-DscResource -ModuleName "PSDscResources" -ModuleVersion "2.5.0.0" -Name "User"

But both the ISE and VSCode give me an error that the resource can't be found. I know the syntax is correct because this line parses correctly.

Import-DscResource -ModuleName "xTimeZone" -ModuleVersion "1.6.0.0" -name "xtimezone"

invoke-dscresource says that a resource is not found

PS C:\Windows\system32> Invoke-DscResource -Method test -Name WindowsFeature -Property @{name='RSAT-AD-PowerShell';IncludeAllSubFeature=$true;ens
Present'} -module PSDscResources -Verbose
Invoke-DscResource : Resource WindowsFeature was not found.
At line:1 char:1

  • Invoke-DscResource -Method test -Name WindowsFeature -Property @{name ...
  •   + CategoryInfo          : NotSpecified: (:) [Invoke-DscResource], ArgumentException
      + FullyQualifiedErrorId : System.ArgumentException,Microsoft.PowerShell.DesiredStateConfiguration.Commands.InvokeDscResourceMethodCommand
    

Group: Resource failing when using 'MembersToInclude' to add members to a local group that contains a domain group

I have a DSC file with a resource hashtable configured similar to the following:

Group AdminGroupMembership {
    Ensure           = "Present"
    GroupName        = "Administrators"
    MembersToInclude = @("Member01")
}

When the DSC applies to a domain member server, it fails, even though 'Member01' was successfully added to the group.

What appears to be happening is that MembersToInclude has the resource iterating through all the members of the group to see if 'Member01' is present. Since this is a domain member server, and since PsDscRunAsCredential isn't specified, the failure is being generated when the script attempts to process the [DOMAIN]\Domain Admins group, as it doesn't have access.

The outcome I was is expecting is: since I'm only looking to validate that 'Member01' exists inside the Administrators local group, and since I'm not looking to remove any members from it, DSC would only validate that 'Member01' exists inside the Administrators local group, and it wouldn't try to resolve a domain member when it doesn't have access to Active Directory.

Is this "working as intended" or can this be resolved in a future update?

Service: Resource missing the option to set the startup type to 'Automatic (Delayed Start)'

I would like to see that we add the option to be able to set the startup type to 'Automatic (Delayed Start)'
I propose that we add the value 'AutomaticDelayedStart' to the parameter StartupType.

To know if a service is set to delayed start the resource has to query the registry.

$service = Get-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Services\MSSQLSERVER'
$isDelayedAutostart = $service.DelayedAutostart -eq 1

And to set a resource to delayed start, we need to change that value in the registry to 1 which means 'Automatic (Delayed Start)'. And to remove delayed start we need to set the value to 0 which means that the startup type is set to 'Automatic'.

Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\MSSQLSERVER" `
    -Name "DelayedAutostart" -Value 1 -Type DWORD

Note: When changing this value in the registry it will not directly show in the service.msc (GUI). A restart seem to be necessary for the GUI to reflect the change. This has no bearing for us since we are only interested in the value in the registry and that the change actually are used when next restart occurs. And it does work in my tests, when changing the value to 1 for delayed start and restarting, the service will delay starting up.

Cannot manage registry key with forward slash

I'm working on PowerShell DSC module to manage FogBugz application. Their registry keys contains forward slashes. This cannot be managed by DSC right now.

Sample registry key used by FogBugz web app
screenshot_060817_100444_pm

Sample configuration:

  Registry FogBugzRegistry_fDebug
  {
      Key         = "HKEY_LOCAL_MACHINE\SOFTWARE\Fog Creek Software\FogBugz\C:/Program Files (x86)/FogBugz/website"
      ValueName   = "fDebug"
      ValueData   = "0"
      Ensure      = "Present"
  }

The error message when applying DSC:

PowerShell DSC resource MSFT_RegistryResource  failed to execute Test-TargetResource functionality with error message: (ERROR) Invalid PSDrive 'HKEY_LOCAL_MACHINE\SOFTWARE\Fog
Creek Software\FogBugz\C' specified in registry key 'HKEY_LOCAL_MACHINE\SOFTWARE\Fog Creek Software\FogBugz\C:/Program Files (x86)/FogBugz/website'
    + CategoryInfo          : InvalidOperation: (:) [], CimException
    + FullyQualifiedErrorId : ProviderOperationExecutionFailure
    + PSComputerName        : localhost

Expected behavior: I should be able to manage any valid registry key value by DSC.

Reference: https://msdn.microsoft.com/en-us/library/ms724946(VS.85).aspx

Each key has a name consisting of one or more printable characters. Key names are not case sensitive. Key names cannot include the backslash character (), but any other printable character can be used. Value names and data can include the backslash character.

Group: Allow compounding of 'MembersToInclude'

I'm not sure 'compounding' is the proper word, but this is the challenge I'm facing with the Group resource:

for all computers I would like to check for accounts A + B are in the local Administrators
on a specific computer, I would to check Account C is part of local Administrators

It seems I can't declare Group multiple times for one computer. To workaround, I build a Script for the additional account.

I think newer DSC modules have a 'Name' attribute, so it allows multiple Group declarations on the same Group.

Registry: ValueName should be optional

I feel like the implementation of ValueName as an empty string (without ValueType
or ValueData) to target a Key is a bit clunky. An empty string intuitively targets the (Default) value. Although removal of the (Default) value does imply removal of the Key, it's not intuitive by design. With all due respect, it feels a bit like a hack to add the ability of Key removal.

I believe that ValueName should not be a required property. It's more intuitive that Key removal look like this:

Registry Test
{
    Ensure = 'Absent'
    Key = 'HKLM:\Software\Test'
}

Making this improvement would not require current functionality to break though. As I stated already, removal of the (Default) value implies removal of the Key. We would just be adding a more intuitive Key removal option. This would also allow for additional properties/features to be implemented that don't require a ValueName name property.

Cannot Import PSDscResources

I have the same issue as was described in #47 . But I'm not using any insider build

Name                           Value
----                           -----
PSVersion                      5.1.14409.1005
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.14409.1005
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

As soon as I install PSDscResources, I am not able to compile any mof anymore(wheter I try to load PSDscResources or not), I always get the error

ImportClassResourcesFromModule : Exception calling "ImportClassResourcesFromModule" with "3" argument(s): "Resource name 'WindowsPackageCab' is already being used by another Resource or
Configuration."
At C:\Windows\system32\WindowsPowerShell\v1.0\Modules\PSDesiredStateConfiguration\PSDesiredStateConfiguration.psm1:2109 char:35
+ ... rcesFound = ImportClassResourcesFromModule -Module $mod -Resources $r ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [ImportClassResourcesFromModule], MethodInvocationException
    + FullyQualifiedErrorId : PSInvalidOperationException,ImportClassResourcesFromModule

The server is a Windows 2012 R2

Deploying archive results in error

I'm using PSDscResources 2.7.0 to configure my server - I deploy a website from a ZIP archive.

Error: PowerShell DSC resource MSFT_Archive failed to execute Set-TargetResource functionality with error message: System.InvalidOperationException: An error occurred while attempting copy from the archive to the destination path C:\inetpub\fogbugz\Accessories\API.

VERBOSE: [FB-MS01-LAB]: LCM:  [ Start  Resource ]  [[Archive]FogBugzDistZip]
VERBOSE: [FB-MS01-LAB]: LCM:  [ Start  Test     ]  [[Archive]FogBugzDistZip]
VERBOSE: [FB-MS01-LAB]:                            [[Archive]FogBugzDistZip] Retrieving the state of the archive with path C:\install\FogBugz-8.8.55.zip and
destination C:\inetpub\fogbugz...
VERBOSE: [FB-MS01-LAB]:                            [[Archive]FogBugzDistZip] A directory already exists at the destination path C:\inetpub\fogbugz.
VERBOSE: [FB-MS01-LAB]:                            [[Archive]FogBugzDistZip] Testing if the archive at the destination path C:\inetpub\fogbugz exists...
VERBOSE: [FB-MS01-LAB]:                            [[Archive]FogBugzDistZip] Opening the archive at path C:\install\FogBugz-8.8.55.zip...
VERBOSE: [FB-MS01-LAB]:                            [[Archive]FogBugzDistZip] An item with the same name as the archive entry exists at the destination path
C:\inetpub\fogbugz\Accessories\.
VERBOSE: [FB-MS01-LAB]:                            [[Archive]FogBugzDistZip] The item at the destination path C:\inetpub\fogbugz\Accessories\ has the same name as
 a file archive entry but is not a file.
VERBOSE: [FB-MS01-LAB]:                            [[Archive]FogBugzDistZip] Closing the archive at path C:\install\FogBugz-8.8.55.zip...
VERBOSE: [FB-MS01-LAB]:                            [[Archive]FogBugzDistZip] The archive at path C:\install\FogBugz-8.8.55.zip does not exist at the destination
C:\inetpub\fogbugz.
VERBOSE: [FB-MS01-LAB]:                            [[Archive]FogBugzDistZip] Testing whether or not the state of the archive with path
C:\install\FogBugz-8.8.55.zip and destination C:\inetpub\fogbugz matches the desired state...
VERBOSE: [FB-MS01-LAB]: LCM:  [ End    Test     ]  [[Archive]FogBugzDistZip]  in 0.2050 seconds.
VERBOSE: [FB-MS01-LAB]: LCM:  [ Start  Set      ]  [[Archive]FogBugzDistZip]
VERBOSE: [FB-MS01-LAB]:                            [[Archive]FogBugzDistZip] Setting the state of the archive with path C:\install\FogBugz-8.8.55.zip and
destination C:\inetpub\fogbugz...
VERBOSE: [FB-MS01-LAB]:                            [[Archive]FogBugzDistZip] A directory already exists at the destination path C:\inetpub\fogbugz.
VERBOSE: [FB-MS01-LAB]:                            [[Archive]FogBugzDistZip] Expanding the archive at C:\install\FogBugz-8.8.55.zip to the destination
C:\inetpub\fogbugz...
VERBOSE: [FB-MS01-LAB]:                            [[Archive]FogBugzDistZip] Opening the archive at path C:\install\FogBugz-8.8.55.zip...
VERBOSE: [FB-MS01-LAB]:                            [[Archive]FogBugzDistZip] An item with the same name as the archive entry exists at the destination path
C:\inetpub\fogbugz\Accessories\.
VERBOSE: [FB-MS01-LAB]:                            [[Archive]FogBugzDistZip] Overwriting the item at the path C:\inetpub\fogbugz\Accessories\...
VERBOSE: [FB-MS01-LAB]:                            [[Archive]FogBugzDistZip] Copying the corresponding archive entry to the path
C:\inetpub\fogbugz\Accessories\...
VERBOSE: [FB-MS01-LAB]:                            [[Archive]FogBugzDistZip] Opening the archive entry Accessories/...
VERBOSE: [FB-MS01-LAB]:                            [[Archive]FogBugzDistZip] Closing the archive at path C:\install\FogBugz-8.8.55.zip...
VERBOSE: [FB-MS01-LAB]: LCM:  [ End    Set      ]  [[Archive]FogBugzDistZip]  in 0.1250 seconds.
PowerShell DSC resource MSFT_Archive  failed to execute Set-TargetResource functionality with error message: System.InvalidOperationException: An error occurred
while attempting copy from the archive to the destination path C:\inetpub\fogbugz\Accessories\. ---> System.Management.Automation.MethodInvocationException:
Exception calling ".ctor" with "2" argument(s): "The filename, directory name, or volume label syntax is incorrect.
" ---> System.IO.IOException: The filename, directory name, or volume label syntax is incorrect.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions
options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean
bFromProxy)
   at System.IO.FileStream..ctor(String path, FileMode mode)
   --- End of inner exception stack trace ---
   at System.Management.Automation.DotNetAdapter.AuxiliaryConstructorInvoke(MethodInformation methodInformation, Object[] arguments, Object[] originalArguments)
   at System.Management.Automation.DotNetAdapter.ConstructorInvokeDotNet(Type type, ConstructorInfo[] constructors, Object[] arguments)
   at Microsoft.PowerShell.Commands.NewObjectCommand.CallConstructor(Type type, ConstructorInfo[] constructors, Object[] args)
   --- End of inner exception stack trace ---
    + CategoryInfo          : InvalidOperation: (:) [], CimException
    + FullyQualifiedErrorId : ProviderOperationExecutionFailure
    + PSComputerName        : localhost

Warning when using File resource from PSDesiredStateConfiguration

Would it be possible to include the File resource in PSDscResources, even if nothing has changed from PSDesiredStateConfiguration?

Otherwise, you get a bunch of conflict warnings when you try to Import-Module PSDscResources and Import-Module PSDesiredStateConfiguration into the same config.

Service: Resource doesn't support setting recovery actions

When creating a new Windows Service, you might want to specify the Recovery Action settings. The Service resource doesn't support those, which forces you to implement it manually using a Script resource, that executes:

sc failure <ServiceName> reset=120 actions=restart/60000/restart/120000/restart/180000
sc failureflag <ServiceName> 1

Windows 10 Creators Update: Importing module MSFT_GroupResource failed with error - Method invocation failed because [System.Collections.Hashtable] does not contain a method named 'Replace'

Tried to run my DSC configuration on a Windows 10 Creators Update Azure VM and got this error:

"DSC Configuration completed with error(s). Following are the first few: Importing module MSFT_GroupResource failed with error - Method invocation failed because [System.Collections.Hashtable] does not contain a method named 'Replace'.

This is using the built in desired state configuration module via the Azure DSC Extension version 2.24. The specific resource that causes the problem is this:

    Group AddTestUserToLocalAdminGroup
    {
        DependsOn = "[User]AddTestUser"
        GroupName='Administrators'   
        Ensure= 'Present'             
        MembersToInclude= "SomeUsername"
    }  

Are there any issues with the DSC Resources on Windows 10 Creators Update?

Service: Resource missing Recovery Options

I'm currently having to implement this manually using the Script Resource with sc.exe, however the TestScript resource is really hacky relies on parsing standard output from sc.exe qfailure "MyService", unfortutantly the Get-Service cmdlet is missing many of the ScriptProperties required to test the state (such as FirstFailure, SecondFailure) on Windows Server 2012 R2 Foundation PS 5.1 (works on Windows 10).

There is a Carbon resource for this but it does not support supplying arguments to the service execution path. Has anybody else tackled this issue?

Out of curiosity, what is the process for merging bugs/features from the xPSDesiredStateConfiguration to PSDscResources and vice versa? It seems like all of the bugs/missing essential features I've encountered apply to both repositories.

Group: Creates error on forcing members for builtin Administrators group

Symptom

MSFT_GroupResource will create the following error, if memebers for the builtin group Administrators will be forced via the "Members" attribute

Error Message is Exception calling "Save" with "0" argument(s): "Cannot perform this operation on built-in accounts.

Steps to reproduce

  1. Create a DSC Configuration
  2. Use the Group resssource and force the memebrs of teh Administrators group to the following contents:
Group GroupExample
{
    Ensure = "Present"
    GroupName = "Administrators"
    Members = @( ".\Administrator", "<Domain>\<SamAccountName>")
}
  1. Apply the configuration to the node

Analysis

By tracking down the error the deletion of all members of a group via $group.Members.Clear() could be assigned as the culprit of the error. The latter issued command $group.Save() will first submit the clear() command to the group which will be prevented by the OS because the Administrators group must contain at least contain the local administrator account from the node (localhost). The Administrators group cannot be empty.

Fix

Instead of simply deleteing all members from the group and reassigning the ones from the input parameter Members the implementation must merge the group members between the current members of the group and the input parameter. The following changes has been applied to MSFT_GroupResource.psm1 to resolve the error:

New (internal) function:

function MergeGroupMembers
{
    [OutputType([bool])]
    param
    (
        [System.DirectoryServices.AccountManagement.GroupPrincipal] $Group,
        [System.DirectoryServices.AccountManagement.Principal[]] $Principals
    )
    Set-StrictMode -Version Latest
    [bool] $updated = $false
    if ($Principals -ne $null)
    {        
        foreach($principal in $Principals)
        {
            if ($group.Members.Contains($principal))
            {
                continue
            }	    
            Write-Verbose ("Adding principal [$principal] to group [$group]")	    
            $group.Members.Add($principal)
            $updated = $true
        }
        foreach($principal in @($group.Members)) 
        {
            if ($Principals.Contains($principal))
            {
                continue
            }	    
            if ($group.Sid -eq "S-1-5-32-544" -and $principal.Sid -like "S-1-5-21-*-500") {
                Write-Verbose ("Skipping local admin account [$principal] for administrators group [$group]")
                continue
            }
            Write-Verbose ("Removing principal [$principal] from group [$group]")
            $group.Members.Remove($principal)
            $updated = $true
        }
    }
    return $updated
}

Changed the code startign at line 446 as following

if ((MergeGroupMembers -Group $group -Principals $expectedPrincipals) -eq $true)
{
      $saveChanges = $true
}

Remarks

Find attached a zip file with additional information.
MSFT_GroupResource_Error.zip

Resource name 'Archive' is already being used by another Resource or Configuration.

I am getting the same issue as #34 but running windows server 2016, and all updates installed. Version table is:

Name                           Value
----                           -----
PSVersion                      5.1.14393.1770
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.14393.1770
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

I am using PSDSCResources in a composite resource module and my imports look like this:

Import-DscResource -ModuleName PowershellModule -ModuleVersion 0.3
    Import-DscResource -ModuleName xRemoteDesktopAdmin -ModuleVersion 1.1.0.0
    Import-DscResource -ModuleName xCertificate -ModuleVersion 3.0.0.0
    Import-DscResource -ModuleName xComputerManagement -ModuleVersion 3.0.0.0
    Import-DSCResource -ModuleName xNetworking -ModuleVersion 5.2.0.0
    Import-DscResource -ModuleName PSDSCResources -ModuleVersion 2.8.0.0

So i'm not importing several modules on the same line as I've seen in other issues. I'm just testing this one composite resource in my configuration so there are no other modules getting loaded.

I installed the module with Install-Module and if I run get-dscresource it looks like this

192.168.0.63]: PS C:\Users\vagrant\Documents> get-dscresource

ImplementedAs   Name                      ModuleName                     Version    Properties
-------------   ----                      ----------                     -------    ----------
Binary          File                                                                {DestinationPath, Attributes, Checksum, Content...
Binary          SignatureValidation                                                 {SignedItemType, TrustedStorePath}
PowerShell      PSModuleRepositoryReso... PowerShellModule               0.3        {Name, SourceLocation, DependsOn, Ensure...}
PowerShell      PSModuleResource          PowerShellModule               0.3        {Module_Name, DependsOn, Ensure, InstallScope...}
PowerShell      Archive                   PSDesiredStateConfiguration    1.1        {Destination, Path, Checksum, Credential...}
PowerShell      Environment               PSDesiredStateConfiguration    1.1        {Name, DependsOn, Ensure, Path...}
PowerShell      Group                     PSDesiredStateConfiguration    1.1        {GroupName, Credential, DependsOn, Description...}
Composite       GroupSet                  PSDesiredStateConfiguration    1.1        {DependsOn, PsDscRunAsCredential, GroupName, En...
Binary          Log                       PSDesiredStateConfiguration    1.1        {Message, DependsOn, PsDscRunAsCredential}
PowerShell      Package                   PSDesiredStateConfiguration    1.1        {Name, Path, ProductId, Arguments...}
Composite       ProcessSet                PSDesiredStateConfiguration    1.1        {DependsOn, PsDscRunAsCredential, Path, Credent...
PowerShell      Registry                  PSDesiredStateConfiguration    1.1        {Key, ValueName, DependsOn, Ensure...}
PowerShell      Script                    PSDesiredStateConfiguration    1.1        {GetScript, SetScript, TestScript, Credential...}
PowerShell      Service                   PSDesiredStateConfiguration    1.1        {Name, BuiltInAccount, Credential, Dependencies...
Composite       ServiceSet                PSDesiredStateConfiguration    1.1        {DependsOn, PsDscRunAsCredential, Name, Startup...
PowerShell      User                      PSDesiredStateConfiguration    1.1        {UserName, DependsOn, Description, Disabled...}
PowerShell      WaitForAll                PSDesiredStateConfiguration    1.1        {NodeName, ResourceName, DependsOn, PsDscRunAsC...
PowerShell      WaitForAny                PSDesiredStateConfiguration    1.1        {NodeName, ResourceName, DependsOn, PsDscRunAsC...
PowerShell      WaitForSome               PSDesiredStateConfiguration    1.1        {NodeCount, NodeName, ResourceName, DependsOn...}
PowerShell      WindowsFeature            PSDesiredStateConfiguration    1.1        {Name, Credential, DependsOn, Ensure...}
Composite       WindowsFeatureSet         PSDesiredStateConfiguration    1.1        {DependsOn, PsDscRunAsCredential, Name, Ensure...}
PowerShell      WindowsOptionalFeature    PSDesiredStateConfiguration    1.1        {Name, DependsOn, Ensure, LogLevel...}
Composite       WindowsOptionalFeatureSet PSDesiredStateConfiguration    1.1        {DependsOn, PsDscRunAsCredential, Name, Ensure...}
PowerShell      WindowsPackageCab         PSDesiredStateConfiguration    1.1        {Ensure, Name, SourcePath, DependsOn...}
PowerShell      WindowsProcess            PSDesiredStateConfiguration    1.1        {Arguments, Path, Credential, DependsOn...}
PowerShell      Archive                   PSDscResources                 2.8.0.0    {Destination, Path, Checksum, Credential...}
PowerShell      Environment               PSDscResources                 2.8.0.0    {Name, DependsOn, Ensure, Path...}
PowerShell      Group                     PSDscResources                 2.8.0.0    {GroupName, Credential, DependsOn, Description...}
PowerShell      MsiPackage                PSDscResources                 2.8.0.0    {Path, ProductId, Arguments, Credential...}
PowerShell      Registry                  PSDscResources                 2.8.0.0    {Key, ValueName, DependsOn, Ensure...}
PowerShell      Script                    PSDscResources                 2.8.0.0    {GetScript, SetScript, TestScript, Credential...}
PowerShell      Service                   PSDscResources                 2.8.0.0    {Name, BuiltInAccount, Credential, Dependencies...
PowerShell      User                      PSDscResources                 2.8.0.0    {UserName, DependsOn, Description, Disabled...}
PowerShell      WindowsFeature            PSDscResources                 2.8.0.0    {Name, Credential, DependsOn, Ensure...}
PowerShell      WindowsOptionalFeature    PSDscResources                 2.8.0.0    {Name, DependsOn, Ensure, LogLevel...}
PowerShell      WindowsPackageCab         PSDscResources                 2.8.0.0    {Ensure, Name, SourcePath, DependsOn...}
PowerShell      WindowsProcess            PSDscResources                 2.8.0.0    {Arguments, Path, Credential, DependsOn...}
PowerShell      xCertificateExport        xCertificate                   3.0.0.0    {Path, AllowExpired, ChainOption, DependsOn...}
PowerShell      xCertificateImport        xCertificate                   3.0.0.0    {Location, Path, Store, Thumbprint...}
PowerShell      xCertReq                  xCertificate                   3.0.0.0    {Subject, AutoRenew, CARootName, CAServerFQDN...}
PowerShell      xPfxImport                xCertificate                   3.0.0.0    {Location, Path, Store, Thumbprint...}
PowerShell      xWaitForCertificateSer... xCertificate                   3.0.0.0    {CARootName, CAServerFQDN, DependsOn, PsDscRunA...
PowerShell      xComputer                 xComputerManagement            3.0.0.0    {Name, Credential, DependsOn, Description...}
PowerShell      xOfflineDomainJoin        xComputerManagement            3.0.0.0    {IsSingleInstance, RequestFile, DependsOn, PsDs...
PowerShell      xPowerPlan                xComputerManagement            3.0.0.0    {IsSingleInstance, Name, DependsOn, PsDscRunAsC...
PowerShell      xScheduledTask            xComputerManagement            3.0.0.0    {ActionExecutable, ScheduleType, TaskName, Acti...
PowerShell      xVirtualMemory            xComputerManagement            3.0.0.0    {Drive, Type, DependsOn, InitialSize...}
PowerShell      xDefaultGatewayAddress    xNetworking                    5.2.0.0    {AddressFamily, InterfaceAlias, Address, Depend...
PowerShell      xDHCPClient               xNetworking                    5.2.0.0    {AddressFamily, InterfaceAlias, State, DependsO...
PowerShell      xDnsClientGlobalSetting   xNetworking                    5.2.0.0    {IsSingleInstance, DependsOn, DevolutionLevel, ...
PowerShell      xDnsConnectionSuffix      xNetworking                    5.2.0.0    {ConnectionSpecificSuffix, InterfaceAlias, Depe...
PowerShell      xDNSServerAddress         xNetworking                    5.2.0.0    {AddressFamily, InterfaceAlias, Address, Depend...
PowerShell      xFirewall                 xNetworking                    5.2.0.0    {Name, Action, Authentication, DependsOn...}
PowerShell      xFirewallProfile          xNetworking                    5.2.0.0    {Name, AllowInboundRules, AllowLocalFirewallRul...
PowerShell      xHostsFile                xNetworking                    5.2.0.0    {HostName, DependsOn, Ensure, IPAddress...}
PowerShell      xIPAddress                xNetworking                    5.2.0.0    {AddressFamily, InterfaceAlias, DependsOn, IPAd...
PowerShell      xNetAdapterBinding        xNetworking                    5.2.0.0    {ComponentId, InterfaceAlias, DependsOn, PsDscR...
PowerShell      xNetAdapterLso            xNetworking                    5.2.0.0    {Name, Protocol, State, DependsOn...}
PowerShell      xNetAdapterName           xNetworking                    5.2.0.0    {NewName, DependsOn, DriverDescription, IgnoreM...
PowerShell      xNetAdapterRDMA           xNetworking                    5.2.0.0    {Name, DependsOn, Enabled, PsDscRunAsCredential}
PowerShell      xNetAdapterRsc            xNetworking                    5.2.0.0    {Name, Protocol, State, DependsOn...}
PowerShell      xNetAdapterRss            xNetworking                    5.2.0.0    {Enabled, Name, DependsOn, PsDscRunAsCredential}
PowerShell      xNetBIOS                  xNetworking                    5.2.0.0    {InterfaceAlias, Setting, DependsOn, PsDscRunAs...
PowerShell      xNetConnectionProfile     xNetworking                    5.2.0.0    {InterfaceAlias, DependsOn, IPv4Connectivity, I...
PowerShell      xNetworkTeam              xNetworking                    5.2.0.0    {Name, TeamMembers, DependsOn, Ensure...}
PowerShell      xNetworkTeamInterface     xNetworking                    5.2.0.0    {Name, TeamName, DependsOn, Ensure...}
PowerShell      xRoute                    xNetworking                    5.2.0.0    {AddressFamily, DestinationPrefix, InterfaceAli...
PowerShell      xRemoteDesktopAdmin       xRemoteDesktopAdmin            1.1.0.0    {Ensure, DependsOn, PsDscRunAsCredential, UserA...

Anyone have any ideas?

MSFT_Archeive Resource failed to executed Test-TargetResource functionality

Hi,

I am attempting to use the DSC Archive Resource but I am running into this error message.

Failed to executed Test-TargetResource functionality with error message: An error occurred while opening the file C:\Program Files (x86)\longpath\VMUtil.pm

I was able to unzip the file manually and use the File Resourse to move the files with out issue. I would prefer to use the Archive Resource instead on manually unzipping the zip files.

User: Docker windows container - UserResource FindByIdentity error

I am trying to use the UserResource in order to provision a windows docker container.

The error I see is:

VERBOSE: [7FA4183C543B]: LCM: [ Start Resource ] [[User]IisRemoteAdminUser]
VERBOSE: [7FA4183C543B]: LCM: [ Start Test ] [[User]IisRemoteAdminUser]
VERBOSE: [7FA4183C543B]: LCM: [ End Test ] [[User]IisRemoteAdminUser]
in 0.6100 seconds.
PowerShell DSC resource MSFT_UserResource failed to execute
Test-TargetResource functionality with error message:
System.InvalidOperationException: There could be a possible multiple matches
exception while trying to use the System.DirectoryServices API's.Exception
calling "FindByIdentity" with "2" argument(s): "The Server service is not
started.
"
+ CategoryInfo : InvalidOperation: (:) [], CimException
+ FullyQualifiedErrorId : ProviderOperationExecutionFailure
+ PSComputerName : localhost

My DSC script tries to create a user and assign to the local administrators group:

Note I import the PSDscResources module at the start of the script, due to the answer here which suggested importing PSDesiredStateConfiguration is older and PSDscResources may have this issue fixed: PowerShell/DscResources#235

Configuration BasicIIS
{  

    Import-DscResource -ModuleName PSDscResources 
    node localhost
    {       

 param(
    [Parameter(Mandatory = $true)][PSCredential]$credential,
    [Parameter(Mandatory = $true)][string]$userName
    )
        
        Group AdminGroupIncludeIisRemoteAdminUser
        {
            # This removes TestGroup, if present
            # To create a new group, set Ensure to "Present“            
            Ensure = "Present"
            GroupName = "Administrators"
            MembersToInclude= "$userName"
            Credential = $credential
            DependsOn = "[User]IisRemoteAdminUser"
        }
        User IisRemoteAdminUser # User for remote IIS administration
        {
            Ensure = "Present"  
            UserName = $userName
            Password = $credential# This needs to be a credential object           
        }    
       
    }
}

$userName= "Foo"
$secUserPassword = ConvertTo-SecureString "Passw0rd" -AsPlainText -Force
$userCreds = New-Object System.Management.Automation.PSCredential ($userName, $secUserPassword )

$cd = @{
    AllNodes = @(
        @{
            NodeName = 'localhost'
            PSDscAllowPlainTextPassword = $true
        }
    )
}

BasicIIS -credential $userCreds -userName $userName -ConfigurationData $cd

Start-DscConfiguration -Path .\BasicIIS -Wait -verbose -Force

My docker file looks like this:


# escape=`
FROM microsoft/aspnet

# Following script just does some prep to install some some tools like the nuget module provider for powershell, and chocolatey etc etc.
ADD ./SetupBasicTools.ps1 /SetupBasicTools.ps1
RUN powershell -NoProfile -File C:\SetupBasicTools.ps1

# The following runs the powershell script above with the user resource where I see the error.
ADD ./web/SetupBasicIIS.ps1 /SetupBasicIIS.ps1
RUN powershell -NoProfile -File C:\SetupBasicIIS.ps1 -logsDir C:/logs

Script: Cannot Schedule Job using Script Resource

I've been trying to use a DSC Script resource to toggle the RebootNodeIfNeeded flag in LCM based on datetime so that I can control the patching reboot window.

Since I don't seem to be able to make the execution of one configuration step dependent on another or replace the boolean true or false setting for RebootNodeIfNeeded with an evaluation, I've fallen back to trying to create a powershell scheduled job to define, generate, and apply metaconfig MOF.

Unfortunately I am somehow getting an elevation related error when the below configuration hits the Register-ScheduledJob step in the SetScript.

Configuration UpdateAndScheduleReboot{
 
    Param(
        [string]$NodeName='localhost',
        [datetime]$TargetRebootTime
    )
    
    Import-DscResource –ModuleName ’PSDesiredStateConfiguration’
    Import-DSCResource -ModuleName xPendingReboot
    Import-DSCResource -ModuleName xWindowsUpdate
    $TargetRebootTime = $AllNodes.TargetRebootTime
    Script RebootEnableJob {
        GetScript = {
            return @{Result = "HelloWorld"}
        }
        TestScript = {
            $ScheduledEnableJob = Get-ScheduledJob | ?{$_.Name -eq 'EnableReboot'}
            if ($ScheduledEnableJob){
                if ($true <#Check for time match#>){
                    Write-Verbose "Matching job found"
                    return $true
                } else {
                    Write-Verbose "Matching job found - Stale Trigger Time"
                    return $false
                }

            } else {
                Write-Verbose "No matching job found"
                Return $false
            }
        }
        SetScript = {
            $ScheduledEnableJob = Get-ScheduledJob | ?{$_.Name -eq 'EnableReboot'}
            if ($ScheduledEnableJob){
                Write-Verbose "Modifying Existing Job"
                $ScheduledEnableJob | Set-ScheduledJob -Trigger (New-JobTrigger -Once -At $Using:TargetRebootTime)
            } else {
                Write-Verbose "Creating New Scheduled Job with target trigger time $($Using:TargetRebootTime)"
                Write-Verbose "User: $([System.Security.Principal.WindowsIdentity]::GetCurrent().Name)"
                Write-Verbose "Current User: $env:UserName"
                $EnableJob = @{
                    Name = 'EnableReboot'
                    ScriptBlock = {
                        configuration RebootSetting
                        {
	                        Param(
		                        [string[]]$NodeName = 'localhost'
	                        )
                            LocalConfigurationManager {
                                RebootNodeIfNeeded = $true
                            }
                        }
                        $ConfigPath = "C:\temp\RebootSetting"
                        & ([scriptblock]::Create("RebootSetting -OutputPath $ConfigPath"))
                        Set-DscLocalConfigurationManager -Path $ConfigPath
        
                    }
                    Trigger = New-JobTrigger -Once -At $Using:TargetRebootTime
                    ScheduledJobOption = New-ScheduledJobOption -RunElevated -DoNotAllowDemandStart
                    ErrorAction = 'Stop'
                }
                Register-ScheduledJob @EnableJob
            }
        }
    }

    Script RebootDisableJob {
        GetScript = {
            return @{Result = "HelloWorld"}
        }
        TestScript = {
            $ScheduledDisableJob = Get-ScheduledJob | ?{$_.Name -eq 'DisableReboot'}
            if ($ScheduledDisableJob){
                if ($true <#Check for time match#>){
                    Write-Verbose "Matching job found"
                    return $true
                } else {
                    Write-Verbose "Matching job found - Stale Trigger Time"
                    return $false
                }

            } else {
                Write-Verbose "No matching job found"
                Return $false
            }
        }
        SetScript = {
            $ScheduledDisableJob = Get-ScheduledJob | ?{$_.Name -eq 'DisableReboot'}
            if ($ScheduledDisableJob){
                Write-Verbose "Modifying Existing Job"
                $ScheduledDisableJob | Set-ScheduledJob -Trigger (New-JobTrigger -Once -At ($Using:TargetRebootTime).AddHours(1.5))
            } else {
                Write-Verbose "Creating New Scheduled Job with target trigger time $Using:TargetRebootTime"
                $DisableJob = @{
                    Name = 'DisableReboot'
                    ScriptBlock = {
                        configuration RebootSetting
                        {
	                        Param(
		                        [string[]]$NodeName = 'localhost'
	                        )
                            LocalConfigurationManager {
                                RebootNodeIfNeeded = $False
                            }
                        }
                        $ConfigPath = "C:\temp\RebootSetting"
                        "RebootSetting -OutputPath $ConfigPath"
                        Set-DscLocalConfigurationManager -Path $ConfigPath
        
                    }
                    Trigger = New-JobTrigger -Once -At $Using:TargetRebootTime
                    ScheduledJobOption = New-ScheduledJobOption -RunElevated -DoNotAllowDemandStart
                }
                Register-ScheduledJob @DisableJob
            }
        }
    }

    xWindowsUpdateAgent MuSecurityImportant {
        IsSingleInstance = 'Yes'
        UpdateNow        = $True
        Source           = 'WindowsUpdate'
        Notifications    = 'ScheduledInstallation'
    }

    xPendingReboot CheckReboot {
        Name = "Check for a pending reboot and trigger if true"
    }
 
}

$ConfigData = @{
    AllNodes = @(
        @{
            NodeName = 'localhost'
            TargetRebootTime = (Get-Date 0:0:0.0).AddDays(3)
            PSDscAllowDomainUser = $true
            PsDscRunAsCredential = $localadmin
        }
    )
}

UpdateAndScheduleReboot -ConfigurationData $ConfigData -OutputPath (Join-Path -Path @($env:SystemDrive) -ChildPath ('Temp\UpdateAndScheduleReboot'))
Start-DscConfiguration -Path C:\temp\UpdateAndScheduleReboot -Force -Wait -Verbose

#install-module -Name @('xComputerManagement','xPendingReboot','xWindowsUpdate') -Force

"Resource name 'WindowsPackageCab' is already being used by another Resource or Configuration."

#34 Seems to be still happening for me on a newer version that mentioned, so opening a new issue to track it

OS: Windows Server 2012 R2

PS C:\dev\dsc> $PSVersionTable

Name Value


PSVersion 5.1.14409.1005
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14409.1005
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

test.ps1

Configuration test {
    [CmdletBinding()]
    param()

    Import-DscResource -ModuleName xWebAdministration, PSDesiredStateConfiguration
	   
        WindowsFeature Web-Server
		{
            Ensure = "Present"
            Name = "Web-Server"
		}
	}
test

PS C:\dev\dsc> . .\test.ps1
ImportClassResourcesFromModule : Exception calling "ImportClassResourcesFromModule" with "3" argument(s): "Resource name
'WindowsPackageCab' is already being used by another Resource or Configuration."
At C:\Windows\system32\WindowsPowerShell\v1.0\Modules\PSDesiredStateConfiguration\PSDesiredStateConfiguration.psm1:2109 char:35

  • ... rcesFound = ImportClassResourcesFromModule -Module $mod -Resources $r ...
  •             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : NotSpecified: (:) [ImportClassResourcesFromModule], MethodInvocationException
    • FullyQualifiedErrorId : PSInvalidOperationException,ImportClassResourcesFromModule

Here is the list of installed DSC Resources

PS C:\dev\dsc> Get-DscResource

ImplementedAs   Name                      ModuleName                     Version    Properties
-------------   ----                      ----------                     -------    ----------
Binary          File                                                                {DestinationPath, Attributes, Checksum, Content...
Binary          SignatureValidation                                                 {SignedItemType, TrustedStorePath}
PowerShell      SQLServerLogin            dSQLServer                     1.0.0.0    {LoginName, DependsOn, Ensure, LoginType...}
PowerShell      SQLServerLoginRole        dSQLServer                     1.0.0.0    {LoginName, DependsOn, Ensure, PsDscRunAsCreden...
PowerShell      SQLServerMaxDop           dSQLServer                     1.0.0.0    {ServerInstance, DependsOn, Ensure, MaxDop...}
PowerShell      Archive                   PSDesiredStateConfiguration    1.1        {Destination, Path, Checksum, Credential...}
PowerShell      Environment               PSDesiredStateConfiguration    1.1        {Name, DependsOn, Ensure, Path...}
PowerShell      Group                     PSDesiredStateConfiguration    1.1        {GroupName, Credential, DependsOn, Description...}
Composite       GroupSet                  PSDesiredStateConfiguration    1.1        {DependsOn, PsDscRunAsCredential, GroupName, En...
Binary          Log                       PSDesiredStateConfiguration    1.1        {Message, DependsOn, PsDscRunAsCredential}
PowerShell      Package                   PSDesiredStateConfiguration    1.1        {Name, Path, ProductId, Arguments...}
Composite       ProcessSet                PSDesiredStateConfiguration    1.1        {DependsOn, PsDscRunAsCredential, Path, Credent...
PowerShell      Registry                  PSDesiredStateConfiguration    1.1        {Key, ValueName, DependsOn, Ensure...}
PowerShell      Script                    PSDesiredStateConfiguration    1.1        {GetScript, SetScript, TestScript, Credential...}
PowerShell      Service                   PSDesiredStateConfiguration    1.1        {Name, BuiltInAccount, Credential, Dependencies...
Composite       ServiceSet                PSDesiredStateConfiguration    1.1        {DependsOn, PsDscRunAsCredential, Name, Startup...
PowerShell      User                      PSDesiredStateConfiguration    1.1        {UserName, DependsOn, Description, Disabled...}
PowerShell      WaitForAll                PSDesiredStateConfiguration    1.1        {NodeName, ResourceName, DependsOn, PsDscRunAsC...
PowerShell      WaitForAny                PSDesiredStateConfiguration    1.1        {NodeName, ResourceName, DependsOn, PsDscRunAsC...
PowerShell      WaitForSome               PSDesiredStateConfiguration    1.1        {NodeCount, NodeName, ResourceName, DependsOn...}
PowerShell      WindowsFeature            PSDesiredStateConfiguration    1.1        {Name, Credential, DependsOn, Ensure...}
Composite       WindowsFeatureSet         PSDesiredStateConfiguration    1.1        {DependsOn, PsDscRunAsCredential, Name, Ensure...}
PowerShell      WindowsOptionalFeature    PSDesiredStateConfiguration    1.1        {Name, DependsOn, Ensure, LogLevel...}
Composite       WindowsOptionalFeatureSet PSDesiredStateConfiguration    1.1        {DependsOn, PsDscRunAsCredential, Name, Ensure...}
PowerShell      WindowsPackageCab         PSDesiredStateConfiguration    1.1        {Ensure, Name, SourcePath, DependsOn...}
PowerShell      WindowsProcess            PSDesiredStateConfiguration    1.1        {Arguments, Path, Credential, DependsOn...}
PowerShell      Environment               PSDscResources                 2.4.0.0    {Name, DependsOn, Ensure, Path...}
PowerShell      Group                     PSDscResources                 2.4.0.0    {GroupName, Credential, DependsOn, Description...}
PowerShell      Registry                  PSDscResources                 2.4.0.0    {Key, ValueName, DependsOn, Ensure...}
PowerShell      Script                    PSDscResources                 2.4.0.0    {GetScript, SetScript, TestScript, Credential...}
PowerShell      Service                   PSDscResources                 2.4.0.0    {Name, BuiltInAccount, Credential, Dependencies...
PowerShell      User                      PSDscResources                 2.4.0.0    {UserName, DependsOn, Description, Disabled...}
PowerShell      WindowsFeature            PSDscResources                 2.4.0.0    {Name, Credential, DependsOn, Ensure...}
PowerShell      WindowsOptionalFeature    PSDscResources                 2.4.0.0    {Name, DependsOn, Ensure, LogLevel...}
PowerShell      WindowsPackageCab         PSDscResources                 2.4.0.0    {Ensure, Name, SourcePath, DependsOn...}
PowerShell      WindowsProcess            PSDscResources                 2.4.0.0    {Arguments, Path, Credential, DependsOn...}
PowerShell      xDisk                     xStorage                       2.9.0.0    {DiskNumber, DriveLetter, AllocationUnitSize, D...
PowerShell      xDiskAccessPath           xStorage                       2.9.0.0    {AccessPath, DiskNumber, AllocationUnitSize, De...
PowerShell      xMountImage               xStorage                       2.9.0.0    {ImagePath, Access, DependsOn, DriveLetter...}
PowerShell      xWaitForDisk              xStorage                       2.9.0.0    {DiskNumber, DependsOn, PsDscRunAsCredential, R...
PowerShell      xWaitForVolume            xStorage                       2.9.0.0    {DriveLetter, DependsOn, PsDscRunAsCredential, ...
PowerShell      xIisFeatureDelegation     xWebAdministration             1.17.0.0   {OverrideMode, SectionName, DependsOn, PsDscRun...
PowerShell      xIisHandler               xWebAdministration             1.17.0.0   {Ensure, Name, DependsOn, PsDscRunAsCredential}
PowerShell      xIisLogging               xWebAdministration             1.17.0.0   {LogPath, DependsOn, LogFlags, LogFormat...}
PowerShell      xIisMimeTypeMapping       xWebAdministration             1.17.0.0   {Ensure, Extension, MimeType, DependsOn...}
PowerShell      xIisModule                xWebAdministration             1.17.0.0   {Name, Path, RequestPath, Verb...}
PowerShell      xSSLSettings              xWebAdministration             1.17.0.0   {Bindings, Name, DependsOn, Ensure...}
PowerShell      xWebApplication           xWebAdministration             1.17.0.0   {Name, PhysicalPath, WebAppPool, Website...}
PowerShell      xWebAppPool               xWebAdministration             1.17.0.0   {Name, autoShutdownExe, autoShutdownParams, aut...
PowerShell      xWebAppPoolDefaults       xWebAdministration             1.17.0.0   {ApplyTo, DependsOn, IdentityType, ManagedRunti...
PowerShell      xWebConfigKeyValue        xWebAdministration             1.17.0.0   {ConfigSection, Key, WebsitePath, DependsOn...}
PowerShell      xWebsite                  xWebAdministration             1.17.0.0   {Name, ApplicationPool, ApplicationType, Authen...
PowerShell      xWebSiteDefaults          xWebAdministration             1.17.0.0   {ApplyTo, AllowSubDirConfig, DefaultApplication...
PowerShell      xWebVirtualDirectory      xWebAdministration             1.17.0.0   {Name, PhysicalPath, WebApplication, Website...}


PS C:\dev\dsc>

Do I miss some patch ?
Update for Windows (KB3191564) is already installed.

Thanks

User resource fails if "Server" service is not running

"Server" service required for "User" resource to operate. If that service is stopped User resource fails.
Steps to reproduce

Get-service Server | Stop -Service

If you use user resource now it will fail with error below

[A-MOBL3]: LCM:  [ Start  Set      ]
[A-MOBL3]: LCM:  [ Start  Resource ]  [[User]LocalAdmin]
[A-MOBL3]: LCM:  [ Start  Test     ]  [[User]LocalAdmin]
[A-MOBL3]: LCM:  [ End    Test     ]  [[User]LocalAdmin]  in 0.0930 seconds.
PowerShell DSC resource MSFT_UserResource  failed to execute Test-TargetResource functionality with error message: The 
variable '$user' cannot be retrieved because it has not been set. 
    + CategoryInfo          : InvalidOperation: (:) [], CimException
    + FullyQualifiedErrorId : ProviderOperationExecutionFailure
    + PSComputerName        : localhost
 
[A-MOBL3]: LCM:  [ End    Set      ]
The SendConfigurationApply function did not succeed.
    + CategoryInfo          : NotSpecified: (root/Microsoft/...gurationManager:String) [], CimException
    + FullyQualifiedErrorId : MI RESULT 1
    + PSComputerName        : localhost
 
Operation 'Invoke CimMethod' complete.
Time taken for configuration job to complete is 0.336 seconds

Renaming an existing user with DSC

Hello,

I'm interested in renaming an existing user with DSC. As I saw so far, the only thing you can do with the module PSDscResources is creating or deleting users.

I'm thinking of creating a resource for this purpose. Is this the right repo for this or is there any other?

if (-not (Test-IsNanoServer)) fails on 2008r2 systems

if (-not (Test-IsNanoServer)) calls Get-ComputerInfo

Get-ComputerInfo : Unable to find an entry point named 'GetFirmwareType' in DLL 'kernel32.dll'.

This only fails on 2008r2. Known issue: PowerShell/PowerShell#3023 Works on 2012 and above.

Need to add some sort of test for OS version first:

$osbuild = (Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" -Name CurrentBuild).CurrentBuild

if $osbuild -lt "9200"

Environment: Multiple Path entries : a conflict was detected between resources [Environment]SetMySQLBinaryPathVariable and [Environment]PHPPathEnvironmentVariable

Fails because the name value must be 'Path' but this this is used as a unique key.
Couldn't find any issues raised regarding this, still a problem in 2.6.0.0.
Is the general accepted solution to use a custom Script resource?

Related:
https://windowsserver.uservoice.com/forums/301869-powershell/suggestions/11088876-dsc-environment-resource-does-not-allow-duplicate
https://powershell.org/forums/topic/why-are-the-resourcekey-combination-required-to-be-unique/

Importing PSDscResources to Azure Automation DSC fails

When trying to import the PSDscResources module to Azure Automation, it fails with the following error:

Error extracting the activities from module PSDscResources. Extraction failed with the following error: Orchestrator.Shared.AsyncModuleImport.ModuleImportException: An error occurred during module validation. When importing the module to an internal PowerShell session, it was not able to be loaded by PowerShell. There is likely an issue with the contents of the module that results in PowerShell's not being able to load it. Please verify that the module imports successfully in a local PowerShell session, correct any issues, and then try importing again.

Resource name '<resource>' is already being used by another Resource or Configuration.

I am attempting to use this resource on a Windows Server 2016 server. I am receiving an error telling me that the resource is already being used by another Resource or configuration.

I installed the resource per the documentation:

Install-Module PSDscResources

To troubleshoot, I've stripped out as much code as a I could to reproduce the error:

Configuration TerminalServer {

    Import-DscResource -ModuleName PSDscResources     
 }

When executing this configuration, I receive the following error:

At line:4 char:5
+     Import-DscResource -ModuleName PSDscResources
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Resource name 'Environment' is already being used by another Resource or Configuration.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : DuplicateKeywordDefinition

Prior to 2.4.0.0, the error message referenced 'Group' instead of environment. It seems like there is some sort of conflict with the inbox resoure, PSDesiredStateConfiguration.

For reference, here are the DSC Resources I have installed:

ImplementedAs   Name                      ModuleName                     Version    Properties               
-------------   ----                      ----------                     -------    ----------               
Binary          File                                                                {DestinationPath, Attr...
Binary          SignatureValidation                                                 {SignedItemType, Trust...
PowerShell      Archive                   PSDesiredStateConfiguration    1.1        {Destination, Path, Ch...
PowerShell      Environment               PSDesiredStateConfiguration    1.1        {Name, DependsOn, Ensu...
PowerShell      Group                     PSDesiredStateConfiguration    1.1        {GroupName, Credential...
Binary          Log                       PSDesiredStateConfiguration    1.1        {Message, DependsOn, P...
PowerShell      Package                   PSDesiredStateConfiguration    1.1        {Name, Path, ProductId...
PowerShell      Registry                  PSDesiredStateConfiguration    1.1        {Key, ValueName, Depen...
PowerShell      Script                    PSDesiredStateConfiguration    1.1        {GetScript, SetScript,...
PowerShell      Service                   PSDesiredStateConfiguration    1.1        {Name, BuiltInAccount,...
PowerShell      User                      PSDesiredStateConfiguration    1.1        {UserName, DependsOn, ...
PowerShell      WaitForAll                PSDesiredStateConfiguration    1.1        {NodeName, ResourceNam...
PowerShell      WaitForAny                PSDesiredStateConfiguration    1.1        {NodeName, ResourceNam...
PowerShell      WaitForSome               PSDesiredStateConfiguration    1.1        {NodeCount, NodeName, ...
PowerShell      WindowsFeature            PSDesiredStateConfiguration    1.1        {Name, Credential, Dep...
PowerShell      WindowsOptionalFeature    PSDesiredStateConfiguration    1.1        {Name, DependsOn, Ensu...
PowerShell      WindowsPackageCab         PSDesiredStateConfiguration    1.1        {Ensure, Name, SourceP...
PowerShell      WindowsProcess            PSDesiredStateConfiguration    1.1        {Arguments, Path, Cred...
PowerShell      Environment               PSDscResources                 2.4.0.0    {Name, DependsOn, Ensu...
PowerShell      Group                     PSDscResources                 2.4.0.0    {GroupName, Credential...
Composite       GroupSet                  PSDscResources                 2.4.0.0    {DependsOn, PsDscRunAs...
Composite       ProcessSet                PSDscResources                 2.4.0.0    {DependsOn, PsDscRunAs...
PowerShell      Registry                  PSDscResources                 2.4.0.0    {Key, ValueName, Depen...
PowerShell      Script                    PSDscResources                 2.4.0.0    {GetScript, SetScript,...
PowerShell      Service                   PSDscResources                 2.4.0.0    {Name, BuiltInAccount,...
Composite       ServiceSet                PSDscResources                 2.4.0.0    {DependsOn, PsDscRunAs...
PowerShell      User                      PSDscResources                 2.4.0.0    {UserName, DependsOn, ...
PowerShell      WindowsFeature            PSDscResources                 2.4.0.0    {Name, Credential, Dep...
Composite       WindowsFeatureSet         PSDscResources                 2.4.0.0    {DependsOn, PsDscRunAs...
PowerShell      WindowsOptionalFeature    PSDscResources                 2.4.0.0    {Name, DependsOn, Ensu...
Composite       WindowsOptionalFeatureSet PSDscResources                 2.4.0.0    {DependsOn, PsDscRunAs...
PowerShell      WindowsPackageCab         PSDscResources                 2.4.0.0    {Ensure, Name, SourceP...
PowerShell      WindowsProcess            PSDscResources                 2.4.0.0    {Arguments, Path, Cred...

Powershell Version Information:

PS C:\> $PSVersionTable

Name                           Value                                                                         
----                           -----                                                                         
PSVersion                      5.1.14393.0                                                                   
PSEdition                      Desktop                                                                       
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                       
BuildVersion                   10.0.14393.0                                                                  
CLRVersion                     4.0.30319.42000                                                               
WSManStackVersion              3.0                                                                           
PSRemotingProtocolVersion      2.3                                                                           
SerializationVersion           1.1.0.1                       

Group: Unable to add Different forest User to Local Group

I am running the following resource
       Group AddUser
    {
            GroupName = "Administrators"
            MembersToInclude = @("DOMAINB\USER1")
    Credential = $DomainBCredential
            Ensure = 'Present'
    }

There are two forests with a single domain each, Computer1 is in domainA and user1 is in domainB. There is a full trust relationship between domains, it should be noted that NETBIOS name is not the same as FQDN on either forest.

I am attempting to add User1 to the local administrators group on Computer1. It should be noted that a number of additional users from domainA are already added into the Computer1 administrative user group via Group Policy, there are also a number of orphaned SIDs. This operation succeeds if done manually.

The credential is to another account on DomainB and has domain admin rights. When running the code I get the following error:

VERBOSE: [COMPUTERNAME]: [[Group]AddUser] Resolving DOMAINB in the Domain Admins domain.
Exception calling "FindByIdentity" with "3" argument(s): "The user name or password is
incorrect.
"
+ CategoryInfo : NotSpecified: (:) [], CimException
+ FullyQualifiedErrorId : COMException,ResolveSidToPrincipal
+ PSComputerName : COMPUTERNAME.DOMAINA.com

When running the exact same configuration using the xGroup resource the configuration resolves and runs correctly. All parameters where kept in memory so the actual username and password couldn't have had a typo. Unfortunately there is a secondary issue with xGroup which I'll post separately.

Update Test-IsNanoServer to use reliable method

The current Test-IsNanoServer function is not using a reliable method of detection of Nano Server.

Please see this comment from @TravisEz13

This is the code we should be using:

function Test-IsNanoServer
{
    if(Test-Command -Name Get-ComputerInfo)
    {
        $computerInfo = Get-ComputerInfo

        if("Server" -eq $computerInfo.OsProductType -and "NanoServer" -eq $computerInfo.OsServerLevel)
        {
            return $true
        }
    }         

    return $false
} 

Registry: Resource needs to delete all values under a key

This scenario is from Bobby Reed for the Baseline Management scenario.
Group Policies sometimes have a *delval command which clears all values under a key and then inserts a new key.

Imagine if I allowed a compromised and outdated cipher suite in the Registry Key. Without **delval, DSC would never catch it, as it would just ensure that the ALLOWED cipher suites were present. GROUP POLICY however, WOULD catch it because it is still processing the **delval properly.

That made me think of another discussion @kwirkykat had for the SecurityPolicy module: dsccommunity/SecurityPolicyDsc#28 (comment)

I think the Registry resource needs something like an explicit “Include”/"Exclude" parameter along the lines the Group parameter Katie describes: https://github.com/powershell/psdscresources#group

WindowsProcess: Intermittent failure in MSFT_WindowsProcess.Integration.Tests.ps1

I ran into this failure in one of my builds.

[00:18:54] [-] Should be able to find the log file after configuration 64ms
[00:18:54] Expected: {True}
[00:18:54] But was: {False}
[00:18:54] at , C:\projects\psdscresources\Tests\Integration\MSFT_WindowsProcess.Integration.Tests.ps1: line 145
[00:18:54] 145: $pathResult | Should Be $true

Attaching build log.

log.txt

File times are not restored correctly on a German system

I currently use this resource to extract archives on a german system. Files with dates october to december are extracted but throw an exception while updating the timestamp, the others are tagged with timestamps where month and day are switched.

This is a problem with regional settings / time conversion [lines 1300++]

Get-ArchiveEntryLastWriteTime returns a regional string, while Set-ItemProperty seems to require an input in en-US format, at least a small local repro suggests this.


`Add-Type -AssemblyName 'System.IO.Compression';
Add-Type -AssemblyName 'System.IO.Compression.FileSystem';

$Path = ".\test.zip"
$newFile = ".\somefile.txt ";

$archive = [System.IO.Compression.ZipFile]::OpenRead($Path);

$archive.Entries[10]

$newDate = (Get-Date -Date $archive.Entries[10].LastWriteTime.DateTime -Format "G");
Set-ItemProperty -LiteralPath $newFile -Name "LastWriteTime" -Value $newDate; # <-- this line throws an exception on a german system

$newDate = (Get-Date -Date $archive.Entries[10].LastWriteTime.DateTime -Format "s");
Set-ItemProperty -LiteralPath $newFile -Name "LastWriteTime" -Value $newDate; # <-- this line works fine`

Might it be a solution to this problem, to switch the date formatting string 'G' (which is a regional string) to 's'?

Windows 10 Creators Update: Resource name 'Archive' is already being used by another Resource or Configuration

Tried to import the PSDscResources module as described here but I keep getting this both on my local Windows 10 Creators Update machine and in a Windows 10 Creators Update based Azure VM that uses the Azure DSC Extension:

  • Import-DscResource -ModuleName PSDscResources
    

2017-05-03T20:29:55.0542055Z VERBOSE: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2017-05-03T20:29:55.0542055Z VERBOSE: Resource name 'Archive' is already being used by another Resource or Configuration..
2017-05-03T20:29:55.0542055Z VERBOSE: Please correct the input and retry executing the extension.".

Are there any known issues with DSC and Windows 10 Creators Update?

Get-InvalidArgumentRecord params should match New-InvalidArgumentException

I've been copying a lot of the code from the CommonResourceHelper.psm1 and CommonTestsHelper.psm1 into some of the other DSC Resources (starting with FSRMDsc) and have noticed that the parameters and design of these functions is different. It would make them much easier to use (IMHO) if they matched.

For example I think this would be better:

function Get-InvalidArgumentRecord
{
    [CmdletBinding()]
    param
    (
        [Parameter(Mandatory = $true)]
        [ValidateNotNullOrEmpty()]
        [String]
        $Message,

        [Parameter(Mandatory = $true)]
        [ValidateNotNullOrEmpty()]
        [String]
        $ArgumentName
    )

    $argumentException = New-Object `
        -TypeName 'ArgumentException' `
        -ArgumentList @( $Message,$ArgumentName )
    $newObjectParams = @{
        TypeName = 'System.Management.Automation.ErrorRecord'
        ArgumentList = @( $argumentException, $ArgumentName, 'InvalidArgument', $null )
    }
    return New-Object @newObjectParams
}

This would mean that the call to throw the exception would be identical (except for the cmdlet name) to the call to create the ErrorRecord to use in a unit test.

This is definitely a minor thing, but as I'm adopting this across more and more resources it would make it way easier 😄

Group resource failing on Nano server.

I am trying to use the Group resource to manage members of the administrators group on nano server but getting an error on Test-TargetResource. The same configuration works fine on a GUI server.

It seems to be line 85 and 89 in the function Test-TargetResourceOnNanoServer that is failing if $groupMembers is only containing one Local user member. This could be because Get-MembersOnNanoServer is returning a string instead of a array. It is working i typecast the variable $groupMembers to array the .Count is working

Also the Function Get-MembersOnNanoServer is only returning local members and not including domain members. What is the reason for that?
As i see it the function will then never verify that domain users is added to the group and always add them.

#--- ERROR ---#
PowerShell DSC resource MSFT_GroupResource failed to execute Test-TargetResource functionality with error message: The property 'Count' cannot be found on this object. Verify that the property exists.
+ CategoryInfo : InvalidOperation: (:) [], CimException
+ FullyQualifiedErrorId : ProviderOperationExecutionFailure
+ PSComputerName : localhost

The SendConfigurationApply function did not succeed.
+ CategoryInfo : NotSpecified: (root/Microsoft/...gurationManager:String) [], CimException
+ FullyQualifiedErrorId : MI RESULT 1
+ PSComputerName : localhost
#--- ERROR ---#

Archive: Subfolder of archive

In MSFT_Archive, is it possible to only extract a sub folder or sub item from an archive? How so? If not, could this be a feature request?

Resolve clashes between PSDesiredStateConfiguration & PsDscResources

Hi,

I'm working with a configuration that uses resources from both PSDesiredStateConfiguration (specifically the File resource) & also PsDscResources (which doesn't have its own version of the File resource). I can get this working by having an Import-DscResource statement for PsDscResources & PSDesiredStateConfiguration is implicitly imported as needed. However, this results in a warning along the lines of "WARNING: The configuration '...' is loading one or more built-in resources without explicitly importing associated modules. Add Import-DscResource –ModuleName 'PSDesiredStateConfiguration' to your configuration to avoid this message.", & I'd like to avoid that if I can.

Questions:

  1. Is there any plan to migrate the File resource into PsDscResources so I can solely use that? Per this issue over at the xPSDesiredStateConfiguration repo it would appear not: Are there any plans or is anyone working on xFile?.
  2. Is there a way to explicitly import just the File resource from PSDesiredStateConfiguration? I can do this for other resources, e.g. Import-DscResource -ModuleName PSDesiredStateConfiguration -Name 'WindowsFeature', but attempting to do this with the File resource results in a "Resource does not exist" message.
  3. Is there a way I can suppress the just "implicit load" warning message?

My strong preference would be either 1 - Be able to use PsDscResources exclusively or 2 - Explicitly import just the File resource. If I need to resort to 3, I'd need a way to ignore this specific warning, but keep any other warnings...

Thanks heaps for help or suggestions,

Dave

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.