Skip to content

Commit

Permalink
Test if any paths are working
Browse files Browse the repository at this point in the history
  • Loading branch information
Trenly committed Nov 5, 2024
1 parent f9a5809 commit 89568ec
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 55 deletions.
1 change: 1 addition & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
"EditorConfig.EditorConfig"
]
}
Test
110 changes: 55 additions & 55 deletions resources/README.md
Original file line number Diff line number Diff line change
@@ -1,55 +1,55 @@
# DSC Resources

This folder contains the initial prototypes for various DSC resources that could be utilized in a configuration yaml.

## Requirements

Before you get started, install the [PSDesiredStateConfiguration v2.0.7](https://www.powershellgallery.com/packages/PSDesiredStateConfiguration/2.0.7) PowerShell package:

```powerShell
Install-Module -Name PSDesiredStateConfiguration -RequiredVersion 2.0.7
```

> To verify that the package is installed, run `Get-InstalledModule` and check that the version is exactly 2.0.7.
## Executing a DSC Resource

PowerShell recursively searches for the module in any of the paths specified in `$env:PSModulePath`. This means you can either copy the DSC Resource module into one of those paths or you can [modify the environment variable](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_psmodulepath?view=powershell-7.3#modifying-psmodulepath) to point to the location of your module.

Once the above step is complete, you should be able to see your loaded DSC resource by running `Get-DSCResource`.

You should now be able to execute the loaded DSC resource by running `Invoke-DSCResource`. Here is a usage example for the Visual Studio DSC Resource to use as a reference for structuring your command:

```powershell
# Define the properties in a hashtable from Get-DscResource
$properties = @{
HttpsUrl = 'https://github.com/microsoft/winget-dsc.git'
RootDirectory = 'C:\Source'
Ensure = 'Present'
}
# Define the parameters for Invoke-DscResource
$params = @{
Name = 'GitClone'
Method = 'Set'
ModuleName = 'GitDsc'
Property = $properties
}
# Invoke the DSC resource
Invoke-DscResource @params
```

## Troubleshooting

If you don't see your DSC Resource loaded, try the following:

1. Try importing the module using `Import-Module`. If the module cannot be imported, then it cannot load the DSC resource.

```powershell
Import-Module <path to DSC module .psd1 file>
```
2. Restarting your shell.
3. Verifying that your syntax in the module is correct. No warning is shown to the user if your PowerShell module file is invalid.
4. Verifying the `$env:PSModulePath` contains the folder path where your module is located.
# DSC Resources

This folder contains the initial prototypes for various DSC resources that could be utilized in a configuration yaml.

## Requirements

Before you get started, install the [PSDesiredStateConfiguration v2.0.7](https://www.powershellgallery.com/packages/PSDesiredStateConfiguration/2.0.7) PowerShell package:

```powerShell
Install-Module -Name PSDesiredStateConfiguration -RequiredVersion 2.0.7
```

> To verify that the package is installed, run `Get-InstalledModule` and check that the version is exactly 2.0.7.
## Executing a DSC Resource

PowerShell recursively searches for the module in any of the paths specified in `$env:PSModulePath`. This means you can either copy the DSC Resource module into one of those paths or you can [modify the environment variable](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_psmodulepath?view=powershell-7.3#modifying-psmodulepath) to point to the location of your module.

Once the above step is complete, you should be able to see your loaded DSC resource by running `Get-DSCResource`.

You should now be able to execute the loaded DSC resource by running `Invoke-DSCResource`. Here is a usage example for the Visual Studio DSC Resource to use as a reference for structuring your command:

```powershell
# Define the properties in a hashtable from Get-DscResource
$properties = @{
HttpsUrl = 'https://github.com/microsoft/winget-dsc.git'
RootDirectory = 'C:\Source'
Ensure = 'Present'
}
# Define the parameters for Invoke-DscResource
$params = @{
Name = 'GitClone'
Method = 'Set'
ModuleName = 'GitDsc'
Property = $properties
}
# Invoke the DSC resource
Invoke-DscResource @params
```

## Troubleshooting

If you don't see your DSC Resource loaded, try the following:

1. Try importing the module using `Import-Module`. If the module cannot be imported, then it cannot load the DSC resource.

```powershell
Import-Module <path to DSC module .psd1 file>
```
2. Restarting your shell.
3. Verifying that your syntax in the module is correct. No warning is shown to the user if your PowerShell module file is invalid.
4. Verifying the `$env:PSModulePath` contains the folder path where your module is located.

0 comments on commit 89568ec

Please sign in to comment.