ComputerManagementDsc icon indicating copy to clipboard operation
ComputerManagementDsc copied to clipboard

Issue with Timezone within ComputerManagementDsc Module shown in example

Open rehan2908 opened this issue 5 years ago • 11 comments

Hello,

I have copied the example of Set Timezone within ComputerManagementDSC module. I saved this as a PS script and whenever i run this via azure automation services then it throws me an Error that Timezone is not a valid parameter.

Configuration TimeZone_SetTimeZone_Config { Import-DSCResource -ModuleName ComputerManagementDsc

Node localhost
{
    TimeZone TimeZoneExample
    {
        IsSingleInstance = 'Yes'
        TimeZone         = 'W. Europe Standard Time'
    }
}

}

Request you to kindly help me on this. I am new to Powershell and trying to get more into this.

Exception calling "NewScriptBlock" with "1" argument(s): "At line:8 char:9 + TimeZone TimeZoneExample + ~~~~~~~~ Undefined DSC resource 'TimeZone'. Use Import-DSCResource to import the resource." (At line:8 char:9 + TimeZone TimeZoneExample + ~~~~~~~~ Undefined DSC resource 'TimeZone'. Use Import-DSCResource to import the resource.)

rehan2908 avatar Oct 16 '19 21:10 rehan2908

Hi did you import the module in Module Galery ?

omiossec avatar Oct 17 '19 14:10 omiossec

I am runnning into the same issue. xTime has been deprecated but this seems to fail in Azure when running dsc node compilations. Module was already imported into Azure modules, but I went ahead and re-imported and still the issue persists. In VSC, it complains about a conflict with the name.

This is the message that VSC gives. Not sure if this is related but I figured I would include as well.

Undefined DSC resource 'TimeZone'. Use Import-DSCResource to import the resource.PowerShell 'TimeZone' is implicitly aliasing 'Get-TimeZone' because it is missing the 'Get-' prefix. This can introduce possible problems and make scripts hard to maintain. Please consider changing command to its full name.PSScriptAnalyzer(PSAvoidUsingCmdletAliases)

Same message as above when trying to compile.

Exception calling "NewScriptBlock" with "1" argument(s): "At line:8 char:9 + TimeZone TimeZoneExample + ~~~~~~~~ Undefined DSC resource 'TimeZone'. Use Import-DSCResource to import the resource." (At line:8 char:9 + TimeZone TimeZoneExample + ~~~~~~~~ Undefined DSC resource 'TimeZone'. Use Import-DSCResource to import the resource.)

jmarrnaz avatar Nov 06 '19 17:11 jmarrnaz

Hi @omiossec,

Sorry about the delay in looking into this.

What version of Windows are you using and what version of this resource module is installed?

PlagueHO avatar Dec 16 '19 01:12 PlagueHO

Azure, latest - 8.3.0 Trying to pull it in on a Win10 manchine but same error on 2016/19 at compilation.

Compilation Exception: Exception calling "NewScriptBlock" with "1" argument(s): "At line:19 char:15 + TimeZone = "GMT Standard Time" + ~~~~~~~~~~~~~~~~~~~ Unexpected token '"GMT Standard Time"' in expression or statement. At line:12 char:3 + rsSysLocale SysLoc + ~~~~~~~~~~~ Undefined DSC resource 'rsSysLocale'. Use Import-DSCResource to import the resource. At line:17 char:3 + rsTime time + ~~~~~~ Undefined DSC resource 'rsTime'. Use Import-DSCResource to import the resource. At line:22 char:3 + rsUserLocale UserLocale + ~~~~~~~~~~~~ Undefined DSC resource 'rsUserLocale'. Use Import-DSCResource to import the resource." (At line:19 char:15 + TimeZone = "GMT Standard Time" + ~~~~~~~~~~~~~~~~~~~ Unexpected token '"GMT Standard Time"' in expression or statement. At line:12 char:3 + rsSysLocale SysLoc + ~~~~~~~~~~~ Undefined DSC resource 'rsSysLocale'. Use Import-DSCResource to import the resource. At line:17 char:3 + rsTime time + ~~~~~~ Undefined DSC resource 'rsTime'. Use Import-DSCResource to import the resource. At line:22 char:3 + rsUserLocale UserLocale + ~~~~~~~~~~~~ Undefined DSC resource 'rsUserLocale'. Use Import-DSCResource to import the resource.)

ps1 config:

Configuration Custom_locale_test {

Import-DSCResource -ModuleName 'PSDesiredStateConfiguration'
Import-DSCResource -ModuleName 'AuditPolicyDSC'
Import-DSCResource -ModuleName 'SecurityPolicyDSC'
Import-DSCResource -ModuleName 'ComputerManagementDsc'
Node localhost
{

	rsSysLocale SysLoc
	{
		SysLocale = "en-GB"
	}

	rsTime time
	{
		TimeZone = "GMT Standard Time"
	}

	rsUserLocale UserLocale
	{
		Name = "UserLocale"
		Culture = "en-GB"
		LocationID = "242"
		LCIDHex = "0809"
		InputLocaleID = "00000809"
	}
}

}

fpschrisiom avatar Jul 07 '20 10:07 fpschrisiom

Hi @fpschrisiom ,

There are a few issues with this config:

  1. rsSysLocale and rsTime are not the correct resource names: Should be SystemLocale and TimeZone respectively.
  2. The TimeZone resource should be like this:
        TimeZone TimeZoneExample
        {
            IsSingleInstance = 'Yes'
            TimeZone         = 'Tonga Standard Time'
        }
  1. There is no UserLocale resource in ComputerManagementDsc. Would be open to adding it though.

PlagueHO avatar Jul 07 '20 21:07 PlagueHO

Ahhh, my bad. Long few days with DSC and had multiple gits open with dsc locales but this git came up with the same error! I swear I thought I copied the code from the wiki and triple checked it. Wishful thinking.

If you wouldn't mind adding it, that would be awesome. I'm having to cobble so much together so I don't have to maintain a server image for our prod cattle.

I got it working.

` TimeZone UK { IsSingleInstance = 'Yes' TimeZone = 'GMT Standard Time' }

SystemLocale en-GB
{
	IsSingleInstance = 'Yes'
	SystemLocale = "en-GB"
}`

fpschrisiom avatar Jul 08 '20 12:07 fpschrisiom

No worries! Glad it's working! I'll add a new issue to track the enhancement,

PlagueHO avatar Jul 08 '20 20:07 PlagueHO

@fpschrisiom - could you raise a new issue detailing the new resource you'd like added? I just want to make sure we get the functional requirements right - e.g. that the resource covers the user scenario correctly.

PlagueHO avatar Jul 08 '20 21:07 PlagueHO

@fpschrisiom - could you raise a new issue detailing the new resource you'd like added? I just want to make sure we get the functional requirements right - e.g. that the resource covers the user scenario correctly.

Certainly! I've added a task on my planner to do it tomorrow. Sorry, notifications not on! I'll sort that too.

fpschrisiom avatar Jul 14 '20 15:07 fpschrisiom

Same issue for me compilation failed with exception error .

Configuration TimeZone_SetTimeZone_Config { Import-DSCResource -ModuleName ComputerManagementDsc

Node localhost
{
    TimeZone UK
    {
        IsSingleInstance = 'Yes'
        TimeZone         = 'Greenwich Mean Time'
    }
}

}

error: Exception calling "NewScriptBlock" with "1" argument(s): "At line:10 char:9 + TimeZone UK + ~~~~~~~~ Undefined DSC resource 'TimeZone'.

anusha189 avatar Sep 02 '22 05:09 anusha189

Hi @anusha189 - what version of the ComputerManagementDsc resource have you got installed? Can you tell me what is the output when you run Get-DscResource -Module ComputerManagementDsc?

PlagueHO avatar Sep 02 '22 06:09 PlagueHO