Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VirtualMemoryFiles: New resource proposal #149

Closed
ChristophHannappel opened this issue Feb 3, 2022 · 3 comments
Closed

VirtualMemoryFiles: New resource proposal #149

ChristophHannappel opened this issue Feb 3, 2022 · 3 comments
Assignees
Labels
question Further information is requested

Comments

@ChristophHannappel
Copy link
Contributor

ChristophHannappel commented Feb 3, 2022

Resource proposal

A new composite ressource to configure the system page file via ComputerManagementDsc\VirtualMemory.
Configure one or more page files for a system.

I've tried do build one myself, but the build fails with:

[-] Composite resource folder count matches composite resource count 49ms
Expected 125, but got 115.
114: $compositeResouces.Count | Should -Be $compositeResouceFolders.Count
at , C:\Users\HannapCh\Repository\CommonTasks\tests\Unit\DSCResources\DscResources.Tests.ps1: line 114

and when used inside the DSCWorkshop Framework it does not recognise the Composite when building the Mof File.

"The term 'VirtualMemoryFiles' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.

Is there an example guide how to add new ones?

Proposed properties

Property Type qualifier Data type Description Default value Allowed values
PropertyName Key String Detailed description None None

Special considerations or limitations

What i've tried:

  • Create a folder VirtualMemoryFiles at /source/DSCRessources/
  • Created the files
    • \source\DSCRessources\VirtualMemoryFiles.schema.psm1
    • \source\DSCRessources\VirtualMemoryFiles.psd1
    • tests\Unit\DSCResources\Assets\Config\VirtualMemoryFiles.yml

VirtualMemoryFiles.schema.psm1 contents:

configuration VirtualMemoryFiles
{
    param (
        [Parameter(Mandatory = $true)]
        [hashtable[]]
        $Files
    )

    Import-DscResource -ModuleName ComputerManagementDsc

    foreach ($file in $Files)
    {
        $executionName = $file.Drive
        (Get-DscSplattedResource -ResourceName VirtualMemory -ExecutionName $executionName -Properties $file -NoInvoke).Invoke($file)
    }
}

VirtualMemoryFiles.psd1 contents:

@{
    RootModule           = 'VirtualMemoryFiles.schema.psm1'

    ModuleVersion        = '0.0.1'

    GUID                 = 'decb37e2-f194-4502-bfee-aed06fafa34d'

    Author               = 'NA'

    CompanyName          = 'NA'

    Copyright            = 'NA'

    DscResourcesToExport = @('VirtualMemoryFiles')
}

VirtualMemoryFiles.yml contents:

Files:
  - Drive: C
  Type: CustomSize
  InitialSize: 4096
  MaximumSize: 4096
  - Drive: P
  Type: CustomSize
  InitialSize: 8192
  MaximumSize: 8192
@ChristophHannappel
Copy link
Contributor Author

ok it seams like i've got a faulty windows 10 vm. I'll try a new one and report back

@raandree raandree self-assigned this Feb 6, 2022
@raandree
Copy link
Collaborator

raandree commented Feb 6, 2022

I skimmed the code and it looks good to me. If the new configuration does not appear as a valid DSC resource, it is usually due to syntax issues in or inconsistent naming.

If it still doesn't work, can you create a PR so I can run through your code more thoroughly, please?

@raandree raandree added the question Further information is requested label Feb 6, 2022
@ChristophHannappel
Copy link
Contributor Author

The issue had been a bad Windows 10 VM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants