Giter VIP home page Giter VIP logo

graniresource's Introduction

GraniResource

DSC Resources published by Grani.Inc.

Notice : 1st/July/2016

Repository name changed from DSCResources to GraniResource to simplify code management.

Installation

You can retrieve Resource through PoweShellGet.

Install-Module GraniResource

Where can I see how to usage of DSCResource?

You may find README.md inside DSCResource\ResourceNameFolder\README.md.

What Inside?

ResourceName FriendlyName Description
cWebPILauncher cWebPILauncher Install WebPlatformInstaller itself
Grani_ACL cACL Allow you to manage ACL entries with this resource.
Grani_CredentialManager cCredentialManager All you to manageCredential Manager entry.
Grani_DomainJoin cDomainJoin Join/Unjoin Domain Resource. This free you from xComputerManagement resource force to specify Host Computer name.
Grani_DotNetFramework cDotNetFramework Manage .NET Framework offline file install/uninstall.
Grani_Download cDownload Download Remote file to local. This include file hash comparison for detecting file change.
Grani_GitHubApiContent cGitHubApiContent Download GitHub content to local through API. This include file hash comparison for detecting file change.
Grani_HostsFile cHostsFile Operate hosts file entry with configuration.
Grani_InheritACL cInheritACL Manage NTFS AccessRule Inheritance. Use cACL to manage each access rules for further usage.
Grani_PendingReboot cPendingReboot Allow you to handle reboot with configuration both LocalConfigurationManager RebootNodeIfNeeded setting as $true/$false.
Grani_PfxImport cPfxImport Import Pfx file into desired CertStore / or Remove pfx from CertStore.
Grani_RegistryKey cRegistryKey Allow you to handle Registry SubKey with Configuration.
Grani_S3Content cS3Content Download and track change with S3 Object and Local File.
Grani_ScheduleTask cScheduledTask Enable you to configure Schedule Task. (Not all property supported, but quiet a lot.)
Grani_ScheduleTaskLog cScheduledTaskLog Enable/Disable Scheduled Task Log
Grani_SymbolicLink cSymbolicLink Create/Remove SymbolicLink.
Grani_TCPAckFrequency cTCPAckFrequency Enable/Disable TCPAckFrequency
Grani_TopShelf cTopShelf Install/Uninstall TopShelf Application
Grani_WebPI cWebPI Install WebPlatformInstaller Products(You cannot uninstall from WebPI)

Directory Tree

DirectoryName Description
Designer Contains xDSCResourceDesigner script to create *.schame.mof and *.psm1.
DSCResource Contains DSC Resource source code.
Package Contains Zip file for release tags.
Test Contains Pester and Configuration Tests for each DSC Resource.

How to release new version

Creating new package zip is Fully integrated with Visual Studio.

  1. Open GraniResource.Sln with Visual Studio.
  2. Open Property for DSCResources.
  3. Go to Assembly Information.
  4. Increment Assetmbly version. This version will be automatically used in GraniResource.psd1 and zip file naming.
  5. Change Build setting to Release build and run build.
  6. Now you will find new DSC Module is created in TmpPackage\GraniResource, and zip file is created in Package\GraniResource_{AssemblyVersion}.zip.

graniresource's People

Contributors

guitarrapc avatar rajbos 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

graniresource's Issues

GraniResource recognized as Module Version 0.0 with PowerShell 4.0

This is because PowerShell 4.0 doesn't have DscResourceToExport key in .psd1.

As these are not supported in PowerShell 4.0 and this section cause Module Version in mof to be force "0.0"

Due to PowerShell 5.0 have this parameter while PowerShell 4.0 don't, this is breaking change for PowerShell DSC.

With GraniResource, this DSC Module supports from PowerShell 4.0, so will remove DscResourceToExport key from psd1

Pre-action for S3Content Change detection

cS3Content is working perfect, however there are some condition which won't to run Pre-action of download.

Currently there are no workaround to detect s3 content, without ScriptResource:(, I think better to create cS3ContentChangeDetect Resource for custom action invoker.

cGitHumAPI Encoding cause CRLF -> LF

In some situations, it seems CRLF content on GitHub will broken into LF by application/json ContentType.

This should be due to Convert.FromBase64String() -> Text.Encoding.UTF8.GetString().

https://github.com/guitarrapc/DSCResources/blob/master/Custom/GraniResource/DSCResources/Grani_GitHubApiContent/Grani_GitHubApiContent.psm1#L588

Workaround

Use ContentType as application/vnd.github.v3.raw. GitHub API will return raw content without base64encoding, and Resource will write Stream directly into File. Thus convert will not happen and issue can be avoid.

See following.

https://github.com/guitarrapc/DSCResources/tree/master/Custom/GraniResource/DSCResources/Grani_GitHubApiContent#tips

cCredentialManager Resource should change Key from Target Property to Name property

Description of Issue

CredentialManager supporting PsRunAsCredential to manage not only SYSTEM Account but others.

However if you wan to manage "same target with same credential" for multiple account is not supported.

Reproduce

With following configuration.

configuration Test
{
    Import-DscResource -Modulename GraniResource
    Node localhost
    {
        cCredentialManager System
        {
            Ensure = $Node.Ensure
            Target = $Node.Target
            Credential = $Node.Credential
        }

        cCredentialManager PsDscRunAsCredential
        {
            Ensure = $Node.Ensure
            Target = $Node.Target
            Credential = $Node.Credential
            PsDscRunAsCredential = $Node.PsDscRunAsCredential
        }
    }
}

$configurationData = @{
    AllNodes = @(
        @{
            NodeName = "localhost"
            PSDscAllowPlainTextPassword = $true
            PSDscAllowDomainUser = $true
            Ensure = "Present"
            Target = "PesterTest"
            Credential = New-Object PSCredential ("Hoge", ("fuga" | ConvertTo-SecureString -Force -AsPlainText))
            PsDscRunAsCredential = New-Object PSCredential ("YourUserName", ("YourAwesomePassword" | ConvertTo-SecureString -Force -AsPlainText))
        }
    )
}

Test -ConfigurationData $configurationData
Start-DscConfiguration -Verbose -Path .\Test -Wait -Force

You will see following errors.

Test-ConflictingResources : A conflict was detected between resources '[cCredentialManager]Present (::6::9::cCredentialManager)' and '[cCredentialManager]Present2 (::14::9::cCr
edentialManager)' in node 'localhost'. Resources have identical key properties but there are differences in the following non-key properties: 'PsDscRunAsCredential'. Values 'Sy
stem.Management.Automation.PSCredential' don't match values 'NULL'. Please update these property values so that they are identical in both cases.
At line:271 char:9
+         Test-ConflictingResources $keywordName $canonicalizedValue $k ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Write-Error], InvalidOperationException
    + FullyQualifiedErrorId : ConflictingDuplicateResource,Test-ConflictingResources
Errors occurred while processing configuration 'Test'.
At C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\PSDesiredStateConfiguration\PSDesiredStateConfiguration.psm1:3705 char:5
+     throw $ErrorRecord
+     ~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (Absent_System:String) [], InvalidOperationException
    + FullyQualifiedErrorId : FailToProcessConfiguration

Expectation

It's should support Same Target, Credential configuration for multiple PsDscRunAsCredential Accounts.

Cannot get ScheduleTask configuration

I've wrote resource for scheduled task:

cScheduleTask {Name} #ResourceName
    {
      Ensure                           = "Present"
      TaskName                         = "TaskName"
      Credential                       = $credential
      Execute                          = "{execute}"
      TaskPath                         = "\"
      ScheduledAt                      = @([DateTime]"00:00:00")
      RepetitionIntervalTimeSpanString = @([TimeSpan]::FromMinutes(10).ToString())
      RepetitionDurationTimeSpanString = @([TimeSpan]::MaxValue.ToString())
      Disable                          = $false
      Hidden                           = $false
      WorkingDirectory                 = "{workingDirectory}"
    }

Resource can be created but when I try Get-DscConfiguration I get:

Get-DscConfiguration : GetConfiguration did not succeed.
At line:1 char:1
+ Get-DscConfiguration -CimSession {name} -Verbose
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (MSFT_DSCLocalConfigurationManager:root/Microsoft/...gurationManager) [Get-DscConfiguration], CimException
    + FullyQualifiedErrorId : MI RESULT 1,Get-DscConfiguration
    + PSComputerName        : {name}

I also get ERROR in ETW:

Message Unable to cast object of type 'System.String' to type 'System.Collections.IList'.
Parameter name: value 
HResult -2147024809 
StackTrack    at Microsoft.Management.Infrastructure.Internal.Data.CimPropertyOfInstance.set_Value(Object value)
   at Microsoft.PowerShell.DesiredStateConfiguration.Internal.ResourceProviderAdapter.GetTargetResource(IntPtr resourceConfigurationInstanceHandle, IntPtr nonResourcePropetiesHandle, IntPtr metaConfigHandle, IntPtr regInstanceHandle, IStreamsHandler plugInStreamsHandler, IntPtr& outputInstanceHandle, IntPtr& errorInstanceHandle)
   at Microsoft.PowerShell.DesiredStateConfiguration.Internal.DscPluginManagedEntryWrapper.Get(IntPtr provContext, IntPtr instance, IntPtr nonResourcePropeties, IntPtr metaConfig, IntPtr regInstance, IntPtr outputInstance, IntPtr extendedError)

cDotNetFramework KB Version does not exist for all Windows product versions

For each Windows Product, after installing DotNet the outcomes are:

  • Windows 7 SP1 / Windows Server 2008 R2 SP1, you will see the Microsoft .NET Framework 4.6.2 as an installed product under Programs and Features in Control Panel.
  • Windows Server 2012 - Hotfix listed KB3151804
  • Windows 8.1 / Windows Server 2012 R2 - Hotfix listed KB3151864

Would this mean that if using Windows 7 SP1 / Windows Server 2008 R2 SP1 the Test Resource would always return false at it simply does a KB check?

It would be great if the resource could take a guess at the KB/installed program based on the product name of Windows it's applying the configuration to, it could possibly switch on this registry key in the test resource.
(Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion' ProductName).ProductName

Documentation at https://support.microsoft.com/en-gb/help/3151800/the-.net-framework-4.6.2-offline-installer-for-windows

Principal not taken into account in Register-ScheduledTask in Grani_ScheduleTask.psm1

Hi,
According to Technet there are 4 possible set of parameters in Register-ScheduledTask: User, Object, Principal and xml (link: https://technet.microsoft.com/en-us/library/jj649811(v=wps.630).aspx)

In function GetRegisterParam you are creating a Principal and trying to pass it to Register-ScheduledTask using an Object parameter set. This does not work, Principal parameter in your call is omitted!

You need to call Register-ScheduledTask with Principal parameter set to make it work correctly, like:
return @{
TaskName = $TaskName
TaskPath = $TaskPath
Action = $scheduleTaskParam.action
Trigger = $scheduleTaskParam.trigger
Settings = $scheduleTaskParam.settings
Principal = $scheduleTaskParam.principal
Description = $scheduleTaskParam.description
}

I discovered this because I needed my task to run in interactive mode, so with LogOnType = "Interactive".
Can you please add also a paraameter that will allow to specify the LogOnType?

[DSCPlatformIssue]New-ScheduledTaskTrigger not compatible with PowerShell 4 and 5

I am getting the following exception when trying out the cScheduleTask resource:
Method "NewTriggerByDaily" not found + CategoryInfo : ObjectNotFound: (PS_ScheduledTask:) [], CimException + FullyQualifiedErrorId : HRESULT 0x80041002,New-ScheduledTaskTrigger + PSComputerName : localhost

This is on a Windows 7 laptop with PowerShell 4 and on a Windows 10 laptop with PowerShell 5 installed.

I have found the following forum discussion that seems to contain the answer:
http://powershell.org/wp/forums/topic/method-newtriggerbyonce-not-found-taskscheduler/

It looks like New-ScheduledTaskTrigger -Daily -At '11AM' constructions need to be replaced by New-JobTrigger -Daily -At 11AM.
I have tested these two expressions on my test devices and both respond as expected, i.e. the first generates the exception New-ScheduledTaskTrigger : Method "NewTriggerByDaily" not found whereas the second replies with a JobTrigger object.

Update Grani_Download to support new TLS versions

File: GraniResource/DSCResources/Grani_Download/Grani_Download.psm1

Ran into an issue in an ARM template where this resource was used. See here.

Fixed it by setting the TLS version before the download:

[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12 -bor [System.Net.SecurityProtocolType]::Tls11 -bor [System.Net.SecurityProtocolType]::Tls

I suggest we add that here as well, to prevent any issues when the host disables older TLS versions.

If you want, I can sent it in as a pull request, but thought it would be nice to open up an issue first.

Symbolic link errors on subsequent applys

I am using the symbolic link resource and it applies successfully the first time and creates the link correctly. But on subsequent runs, it fails.

I think its something to do with the test function as it seems to think that the link doesn't exist and tries to re-create it when it already exists.

My DSC config is

    $documents = [Environment]::GetFolderPath("MyDocuments")    
    cSymbolicLink powershellProfileLink {
      Ensure          = "Present"
      SourcePath      = "C:\code\powershell-profile\"
      DestinationPath = "$documents\WindowsPowerShell\"
      DependsOn       = "[cGitRepository]powershellProfile"
    }

the error message is.

VERBOSE: [NLYBSTQVP4NB88O]: LCM:  [ Start  Resource ]  [[cSymbolicLink]powershellProfileLink]
VERBOSE: [NLYBSTQVP4NB88O]: LCM:  [ Start  Test     ]  [[cSymbolicLink]powershellProfileLink]
VERBOSE: [NLYBSTQVP4NB88O]: LCM:  [ End    Test     ]  [[cSymbolicLink]powershellProfileLink]  in 0.0590 seconds.
VERBOSE: [NLYBSTQVP4NB88O]: LCM:  [ Start  Set      ]  [[cSymbolicLink]powershellProfileLink]
VERBOSE: [NLYBSTQVP4NB88O]:                            [[cSymbolicLink]powershellProfileLink] DestinationPath : 'C:\Users\320047825\OneDrive - Philips\Documents\WindowsPowerShell\',  SourcePath :
'C:\code\powershell-profile\', IsDirectory : 'False'
Exception calling "CreateSymLink" with "3" argument(s): "Cannot create a file when that file already exists"
    + CategoryInfo          : NotSpecified: (:) [], CimException
    + FullyQualifiedErrorId : Win32Exception
    + PSComputerName        : localhost

VERBOSE: [NLYBSTQVP4NB88O]: LCM:  [ End    Set      ]  [[cSymbolicLink]powershellProfileLink]  in 0.1390 seconds.
The PowerShell DSC resource '[cSymbolicLink]powershellProfileLink' with SourceInfo 'C:\code\windows-dev-config\devMachineConfig.ps1::85::5::cSymbolicLink' threw one or more non-terminating errors while running
the Set-TargetResource functionality. These errors are logged to the ETW channel called Microsoft-Windows-DSC/Operational. Refer to this channel for more details.
    + CategoryInfo          : InvalidOperation: (:) [], CimException
    + FullyQualifiedErrorId : NonTerminatingErrorFromProvider
    + PSComputerName        : localhost

VERBOSE: [NLYBSTQVP4NB88O]: LCM:  [ End    Set      ]
The SendConfigurationApply function did not succeed.
    + CategoryInfo          : NotSpecified: (root/Microsoft/...gurationManager:String) [], CimException
    + FullyQualifiedErrorId : MI RESULT 1
    + PSComputerName        : localhost

VERBOSE: Operation 'Invoke CimMethod' complete.
VERBOSE: Time taken for configuration job to complete is 18.029 seconds

Should support MatchSource for cGitHubContet and cS3Content?

Currently File hash is only supported.

Should support.... followings?

  1. Selection of File Hash Algorithm? -> MD5, SHA1, SHA256
  2. Only Name -> If don't want to track change.
  3. CreateDate -> As MSFT do in File Resource
  4. LastWriteDate -> As MSFT do in File Resource

Rather thinking about CreateDate and LastWriteDate, Name match source would be useful in some situation? I don't imagine the condition..... though.

Algorithm support is easy and quickly releasable.

Can not handle Script resource execution by OSVersion

In default Script resource, it evaluates on when creating .mof then generated constraint value. It means if you using PULL Server, all value in the mof will be static and could not handle by Client.
This is because evaluation is done before each client pulling and will not dynamically calculate on client.

In general, this is expected behavior and all resource will only accept constraint value like string or int, then Evaluate on run-time with Custom Resources.

So the solution is simple, just make your dsc resource to handle OSVersion and Script Execution.

cTopShelf not promise Install is always done

as TopShelf Xxxxx.exe install will skip changing current service information when service is already installed.

Thus if there are any path change or others, service should uninstall before installation.

Sporadic error after "Test-DscConfiguration"

Sporadic error after "Test-DscConfiguration"

VERBOSE: [FORS559A]: LCM: [ FAILEDTest ] Completed processing test operation. The operation failed.
Importing module Grani_ScheduleTask failed with error - Cannot add type. The type name 'EnsureType' already exists.
+ CategoryInfo : InvalidOperation: (root/Microsoft/...gurationManager:String) [], CimException
+ FullyQualifiedErrorId : ImportModuleFailed
+ PSComputerName : localhost

cHostsFile : Dynamic DNS Resolver on node side

Currently DNS resolving statically when creating mof on DSC Server.

This is not useful at all, and need to be resolve at node side.

Even node hosts is defined, Resolve-DnsName -Name <TargetDns> -Server <DnsServer> can be handle specific dns.

Would be prefer add Write Key to mof and handle in psm1.

cHostsFile not checking IP change

When same host entry was exit, new host entry will be added last.

However duplicate host entry will be choose from top, and new entry is ignored

Change to psproj

psproj is dead. It won't work in VS2015 in several situation and won't update for over half years.

Let's change to CSProj and reference CSharp Library for complex Resources.

cScheduledTask - The filename or extension is too long with 2016 Core

On Windows 2016 Core, I receive "The filename or extension is too long" error on all configurations that use cScheduledTask.

On Windows 2016 GUI, cScheduledTask works perfectly fine using the exact same config as Core.

VERBOSE: [LABSERVER02]: LCM:  [ Start  Resource ]  [[cScheduleTask]ClearTempDirectoriesScheduledTask]
VERBOSE: [LABSERVER02]: LCM:  [ Start  Test     ]  [[cScheduleTask]ClearTempDirectoriesScheduledTask]
VERBOSE: [LABSERVER02]: LCM:  [ End    Test     ]  [[cScheduleTask]ClearTempDirectoriesScheduledTask]  in 0.0470 seconds.
Invoke-CimMethod : The filename or extension is too long
At C:\Lab\TestSchedule.ps1:20 char:5
+     Invoke-CimMethod -CimSession $ServerName -Name PerformRequiredCon ...
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : AuthenticationError: (:) [Invoke-CimMethod], CimException
    + FullyQualifiedErrorId : Win32Error:206,Microsoft.Management.Infrastructure.CimCmdlets.InvokeCimMethodCommand
    + PSComputerName        : LABSERVER02
cScheduleTask ClearTempDirectoriesScheduledTask
{
    Ensure               = 'Present'
    PsDscRunAsCredential = $Credential
    TaskName             = 'Clear Temp'
    Runlevel             = 'Highest'
    Compatibility        = 'Win8'
    Hidden               = $False
    Disable              = $False
    Execute              = 'powershell.exe'
    Argument             = "-NoProfile -Command `"Remove-Item -Path 'C:\Windows\Temp\*' -Recurse -Exclude 'GuestIndexData.zip' -Force -ErrorAction SilentlyContinue;Remove-Item -Path 'C:\Windows\System32\Configuration\ConfigurationStatus\*' -Include @('*.mof','*.json') -Force -ErrorAction SilentlyContinue;Remove-Item -Path 'C:\Windows\logs\cbs\*' -Recurse -Force -ErrorAction SilentlyContinue`""
    ScheduledAt          = [datetime](New-TimeSpan -Hours 05 -Minutes (Get-Random -Maximum 119)).ToString("hh\:mm\:ss")
    Daily                = $True
}
Name                           Value
----                           -----
PSVersion                      5.1.14393.206
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.14393.206
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

[Announce] Publish on PowerShellGet

Thank you for using GraniResource. I do love to announce this news. Now everyone can retrieve GraniResource from PowerShellGet.

Install-Module GraniResource

image

Hope you like it and waiting for your feedback.

Cheers,
guitarrapc

Enahance xPendingReboot to manage RebootIfNeeded include inside Resource

Description

Enhance to set LCM with configuration, timeout sec.

Why we need this

Current MSFT xPendingReboot required to manage LCM outside resource.

http://blogs.technet.com/b/heyscriptingguy/archive/2014/10/15/use-powershell-dsc-to-check-pending-reboot.aspx

It means we need to run Set-DSCLocalConfigurationManager before setting PULL/PUSH. This can't be acceptable and not useful enough.

Planning to modify to accept change LCM inside resource and would be prefer to set timeout sec.

LCM would be better return to previous value after next configuration.

Configuration Example

Current

xPendingReboot PreTest
{
    Name = "Node will be reboot if Needed."
}

New

cPendingReboot PreTest
{
    Name = "Node will be reboot if Needed."
    WaitTime = 30
    RebootNodeIfNeeded = $true
}

[Enhancement]cScheduledTask TaskPath Property requires \ at first char for Get/Test.

Reference

ref : https://github.com/guitarrapc/DSCResources/issues/49#issuecomment-178571072

Description

If you set cScheduledTask as below it works fine.

configuration present
{
    Import-DscResource -Modulename GraniResource
    Node $AllNodes.Where{$_.Role -eq "localhost"}.NodeName
    {
        cScheduleTask hoge
        {
            Ensure = "Present"
            Execute = "C:\Temp\test.bat"
            TaskName = "TestRenaud2123"
            TaskPath = "\rimes"
            ScheduledAt = [datetime]"00:00:00", [datetime]"01:00:00"
            RepetitionIntervalTimeSpanString = @(([TimeSpan]"00:05:00").ToString())
            RepetitionDurationTimeSpanString = @(([TimeSpan]::MaxValue).ToString())
            Disable = $false
        }
    }
}

But if you set TaskPath without \ on first char, Test always fail and start Set.

configuration present
{
    Import-DscResource -Modulename GraniResource
    Node $AllNodes.Where{$_.Role -eq "localhost"}.NodeName
    {
        cScheduleTask hoge
        {
            Ensure = "Present"
            Execute = "C:\Temp\test.bat"
            TaskName = "TestRenaud2123"
            TaskPath = "rimes"
            ScheduledAt = [datetime]"00:00:00", [datetime]"01:00:00"
            RepetitionIntervalTimeSpanString = @(([TimeSpan]"00:05:00").ToString())
            RepetitionDurationTimeSpanString = @(([TimeSpan]::MaxValue).ToString())
            Disable = $false
        }
    }
}

Todo

  • Test TaskPath first char for \
  • Automatically add \ if there isn't exists.

[Enhancement]Add cPowerShellGet Resource

Now I have confirmed it can host Private PowerShellGet Repository (PSRepository) with Nuget.Server. This is the time to install module with DSC.

However xPowerShellget or similar DSC Resources are not existing yet.

Issue when calling Grani_DotNetFramework

After installing module on both, Windows 10 and Server 2016, I am getting:

PowerShell DSC resource MSFT_PackageResource failed to execute Set-TargetResource functionality with error message: The running command stopped because the
preference variable "ErrorActionPreference" or common parameter is set to Stop: Access is denied
+ 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 : localhostImporting module Grani_DotNetFramework failed with error -At C:\Program
Files\WindowsPowerShell\Modules\GraniResource\3.7.9.0\DscResources\Grani_DotNetFramework\Grani_DotNetFramework.psm1:408 char:26 + if ($result -ne 0) # should be 0 for success uninstallation { + ~ Missing statement block after if ( condition ). At C:\Program Files\WindowsPowerShell\Modules\GraniResource\3.7.9.0\DscResources\Grani_DotNetFramework\Grani_DotNetFramework.psm1:413 char:55
+ elseif ($Ensure -eq [EnsureType]::Present.ToString()) {
+ ~
Unexpected token '{' in expression or statement.
At C:\Program Files\WindowsPowerShell\Modules\GraniResource\3.7.9.0\DscResources\Grani_DotNetFramework\Grani_DotNetFramework.psm1:415 char:22 + if ($result -eq 0) # should be 1 for success installation { + ~ Missing statement block after if ( condition ). At C:\Program Files\WindowsPowerShell\Modules\GraniResource\3.7.9.0\DscResources\Grani_DotNetFramework\Grani_DotNetFramework.psm1:419 char:1
+ }
+ ~
Unexpected token '}' in expression or statement.
At C:\Program Files\WindowsPowerShell\Modules\GraniResource\3.7.9.0\DscResources\Grani_DotNetFramework\Grani_DotNetFramework.psm1:420 char:1 + } + ~ Unexpected token '}' in expression or statement. + CategoryInfo : InvalidOperation: (root/Microsoft/...gurationManager:String) [], CimException + FullyQualifiedErrorId : ImportModuleFailed + PSComputerName : localhost`

By the error message, and I am not sure why this is an issue, "{ }" making trouble. When I reorganize them, all is working as expected.

https://app.leanboard.io/board/705af88f-a126-4b24-aa44-cefb02689ee7

[Enhancement]WebSite resource

as MSFT and PowerShell Org resource never pass TEST.... :(

No one create? .... Then I will..... I don't want to... but..... if.....

Add Checksum Property for cS3Content change detection

As there are several situations that won't like to detect change by FileHash.

Something like want to control more strictly with FileName, means only if file in local server was deleted then download latest key from s3.

I agree with this request and will prepare CheckSum Property to select from FileHash and FileName.

current

configuration hoge
{
    Import-DSCResource -ModuleName GraniResource
    cS3Content fuga
    {
        DestinationPath = "c:\hoge\keyname.zip"
        S3BucketName = "bucketName"
        Key = "keyname.zip"
    }
}

new

CheckSum default will be FileHash. So can be omit for FileHash detection, only required for FileName detection.

configuration hoge
{
    Import-DSCResource -ModuleName GraniResource
    cS3Content fuga
    {
        DestinationPath = "c:\hoge\keyname.zip"
        S3BucketName = "bucketName"
        Key = "keyname.zip"
        CheckSum = "FileName"
    }
}

Error installing .net framework 4.6.1 with cDotNetFramework resource

I'm trying to use the cDotNetFramework resource but with not much luck.
This is my configuration:

cDotNetFramework DotNet461
{
KB = "KB3102436"
InstallerPath = "$software\NDP461-KB3102436-x86-x64-AllOS-ENU.exe"
Ensure = "Present"
NoRestart = $false
LogPath = "$logs\DotNet461.log"
}

And these are the errors I can see on the windows event log:

Job {22503149-FCDE-11E5-80CA-005056B81B83} :
Message Could not find KB from Windows Hotfix list. KB : KB3102436
HResult -2146233087
StackTrack at System.Management.Automation.Interpreter.ThrowInstruction.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)

Job {22503149-FCDE-11E5-80CA-005056B81B83} :
This event indicates that failure happens when LCM is processing the configuration. Error Id is 0x1. Error Detail is The SendConfigurationApply function did not succeed.. Resource Id is [cDotNetFramework]DotNet461 and Source Info is D:\BuildAgent\work\b909d824977baca3\infra\dsc\TeamCity.ps1::26::3::cDotNetFramework. Error Message is PowerShell DSC resource Grani_DotNetFramework failed to execute Set-TargetResource functionality with error message: Could not find KB from Windows Hotfix list. KB : KB3102436 .

Job {22503149-FCDE-11E5-80CA-005056B81B83} :
MIResult: 1
Error Message: PowerShell DSC resource Grani_DotNetFramework failed to execute Set-TargetResource functionality with error message: Could not find KB from Windows Hotfix list. KB : KB3102436
Message ID: ProviderOperationExecutionFailure
Error Category: 7
Error Code: 1
Error Type: MI

Any help would be appreciated.
Thanks

cScheduledTask - 'The user account does not have permission to run this task'

@guitarrapc, when I run the following config and then try to 'Right click' on the Scheduled Task in Task Scheduler and click on "Run", I get the error "The user account does not have permissions to run this task". If I create the same scheduled task using the same account, I don't get any permission issues.

v3.7.6

cScheduleTask MyScheduledTask
{
Ensure = 'Present'
Credential = $Credential
TaskName = 'MyTask-Test123'
Runlevel = 'Highest'
Compatibility = 'Win8'
Hidden = $False
Disable = $False
Execute = 'powershell.exe'
Argument = "-NoProfile -Command "dir""
ScheduledAt = [datetime](New-TimeSpan -Hours 01 -Minutes %28Get-Random -Maximum 119%29).ToString("hh:mm:ss")
Daily = $True
}

cScheduleTask - The RepetitionInterval and RepetitionDuration Job trigger parameters must be specified together

The config below for cScheduledTask worked perfectly fine in 3.7.8.1...

cScheduleTask PowershellHelpUpdateScheduledTask
{
    Ensure                           = 'Present'
    PsDscRunAsCredential             = $Credential
    TaskName                         = 'Powershell Help Update'
    Runlevel                         = 'Highest'
    Compatibility                    = 'Win8'
    Hidden                           = $False
    Disable                          = $False
    Execute                          = 'powershell.exe'
    Argument                         = "-NoProfile -Command `"Update-Help -SourcePath $($Node.PowershellHelpSource) -Module * -Force -ErrorAction SilentlyContinue`""
    TaskPath                         = '\'
    ScheduledAt                      = [DateTime]"2016/02/13 $($Time.Hour):$($Time.Minute):00" # Saturday
    RepetitionIntervalTimeSpanString = [TimeSpan]::FromDays(7).ToString() # run every week
    RepetitionDurationTimeSpanString = [TimeSpan]::MaxValue.ToString() # to forever
}

...but in 3.7.8.3 the following error appears...

Invoke-CimMethod : PowerShell DSC resource Grani_ScheduleTask  failed to execute Set-TargetResource functionality with error message: The RepetitionInterval and RepetitionDuration Job trigger parameters must be specified together. 
At C:\LabCode\Invoke-LabServer.ps1:20 char:5
+     Invoke-CimMethod -CimSession $ServerName -Name PerformRequiredCon ...
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Invoke-CimMethod], CimException
    + FullyQualifiedErrorId : ProviderOperationExecutionFailure,Microsoft.Management.Infrastructure.CimCmdlets.InvokeCimMethodCommand
    + PSComputerName        : LABSERVER01

cS3Content should handle region override

Description

EC2 Windows Server 2016 treat default region in cS3Content. This results Instance could not access to non us-west-2 s3bucket.

Expected behavior

cS3Content could handle bucket as expected, get, set, test.

Actual behavior

cS3Content throw an exception with non-accessible s3bucket.

The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.

Reproduce

configuration InstallHoge
{
    Import-DSCResource -ModuleName GraniResource;
    
    Node localhost
    {
        cS3Content "HogeConfig"
        {
            S3BucketName = "your-awesome-ap-northeast-1-bucket"
            Key = ".hogeconfig"
            DestinationPath = "c:\.hogeconfig"
        }

    }
}

InstallHoge
Start-DscConfiguration -Wait -Verbose -Path .\InstallHoge -Force

Log

VERBOSE: [EC2AMAZ-0LP0P16]: LCM:  [ Start  Resource ]  [[cS3Content]HogeConfig]
VERBOSE: [EC2AMAZ-0LP0P16]: LCM:  [ Start  Test     ]  [[cS3Content]HogeConfig]
VERBOSE: [EC2AMAZ-0LP0P16]:                            [[cS3Content]HogeConfig] Invoking Amazon S3 in region 'us-west-2'
VERBOSE: [EC2AMAZ-0LP0P16]:                            [[cS3Content]HogeConfig] Invoking Amazon S3 operation 'ListObjects' in region 'us-west-2'
The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.
    + CategoryInfo          : NotSpecified: (:) [], CimException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Get-TargetResource
    + PSComputerName        : localhost
 
VERBOSE: [EC2AMAZ-0LP0P16]: LCM:  [ End    Test     ]  [[cS3Content]HogeConfig]  in 6.5240 seconds.
The PowerShell DSC resource '[cS3Content]Git Config' with SourceInfo '::26::9::cS3Content' 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: (:) [], CimException
    + FullyQualifiedErrorId : NonTerminatingErrorFromProvider
    + PSComputerName        : localhost

Unable to create a new schedule task on non-existing or empty TaskPath

Hello,

I have tested the scenario where a task is created on a taskpath that does not exists. The resource exit because it couldn't find a task with the same folder (I checked the code).

The problem is that this scenario is a 101 for DSC when you want to install a fresh new server. I have test the set resource function and it manages to create the task with a new folder. Why do you check existence of a taskpath then ?

Could you please help?
ps: if an empty task folder exists in the scheduler it fails also.

PS 5.1 - Cannot bind argument to parameter 'ScheduledTask' because it is null

When running cScheduledTask on Windows 2012 R2 with Powershell 5.1 (RTM) the following error appears on all cScheduledTask resources.

VERBOSE: [LABSERVER01]: LCM:  [ Start  Resource ]  [[cScheduleTask]PowershellHelpUpdateScheduledTask]
VERBOSE: [LABSERVER01]: LCM:  [ Start  Test     ]  [[cScheduleTask]PowershellHelpUpdateScheduledTask]
VERBOSE: [LABSERVER01]:                            [[cScheduleTask]PowershellHelpUpdateScheduledTask] False
Invoke-CimMethod : Cannot bind argument to parameter 'ScheduledTask' because it is null.
At C:\Test\MyScheduledTask\InvokeDSC.ps1:20 char:5
+     Invoke-CimMethod -CimSession $ServerName -Name PerformRequiredCon ...
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Invoke-CimMethod], CimException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,GetScheduledTask,Microsoft.Management.Infrastructure.CimCmdlets.InvokeCimMethodCommand
    + PSComputerName        : LABSERVER01

Accurate TopShelf process detection

Overview

Currently only checking Service Name | DisplayName with Process path.

https://github.com/guitarrapc/DSCResources/blob/master/Custom/GraniResource/DSCResources/Grani_TopShelf/Grani_TopShelf.psm1#L291

Because when Service stopped then trying to run Service, it throw error when old TopShelf Path is not same as current.

How to handle

Process checking isn't good idea to validate service is TopShelf. May be Win32_Service to detect executable path would be prefer.

unable to install .net framework 4.7.2 offline installer

unable to install .net framework 4.7.2 offline installer
getting error

Error:- PowerShell provider Grani_DotNetFramework failed to execute Set-TargetResource functionality with error message: Installation failed. Installation prevented as
previous installation is not completed until reboot. Please redo after reboot. ExitCode : 16389

steps tried:-

  1. restarted server.
  2. created new server and tried on that server. Getting same error

[Enhancement]ApplicationPool resource

MSFT application pool resource not support specified user, PowerShellOrg seems supported but failed test.

It seems AppCmd is in used with PowerShellOrg resource.... It would prefer if we can handle with C# or PowerShell IIS: Provider for Object handling, not native wrapper.

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.