# How to use PS cmdlets in a DSC resource helper functions?

**URL:** https://forums.powershell.org/t/how-to-use-ps-cmdlets-in-a-dsc-resource-helper-functions/5302
**Category:** DSC
**Created:** [December 3, 2015, 3:54am UTC](https://forums.powershell.org/t/how-to-use-ps-cmdlets-in-a-dsc-resource-helper-functions/5302 "2015-12-03T03:54:41Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![janis-berzins](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@janis-berzins](https://forums.powershell.org/u/janis-berzins)
#### Post date: [December 3, 2015, 3:54am UTC](https://forums.powershell.org/t/how-to-use-ps-cmdlets-in-a-dsc-resource-helper-functions/5302/1 "2015-12-03T03:54:41Z")

</div>

I have created a DSC module that has few helper functions in it. I would like to use a cmdlet in one of the helper functions from a PS module in one of the helper functions that I have included in DSC module.

In my tests the helper function was unable to execute the cmdlet as it was not recognized. Obviously the PS module should be imported before running cmdlet in the DSC’s module helper function.

So is it possible to create some sort of dependence for DSC module that would import PS module that contains this cmdlet?

---

<div class="post-metadata">

### Author: ![donj](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/donj/32/137_2.png) [@donj](https://forums.powershell.org/u/donj)
#### Post date: [December 3, 2015, 3:57am UTC](https://forums.powershell.org/t/how-to-use-ps-cmdlets-in-a-dsc-resource-helper-functions/5302/2 "2015-12-03T03:57:30Z")

</div>

So:

DSC module has Helper Functions.

Helper Functions need to use a command that lives in a normal Module.

Is the Module correctly stored in one of the paths in your PSModulePath environment variable? If not, the Module will need to be loaded ahead of time. Would it be possible to simply put the Module into one of the correct paths?

---

<div class="post-metadata">

### Author: ![janis-berzins](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@janis-berzins](https://forums.powershell.org/u/janis-berzins)
#### Post date: [December 3, 2015, 9:07pm UTC](https://forums.powershell.org/t/how-to-use-ps-cmdlets-in-a-dsc-resource-helper-functions/5302/3 "2015-12-03T21:07:33Z")

</div>

The module is in the correct location.  
How would I load the normal module ahead when DSC module runs and runs the normal command that’s in the normal module?

Do I run the import-module cmdlet in DSC’s module helper function?

---

<div class="post-metadata">

### Author: ![janis-berzins](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@janis-berzins](https://forums.powershell.org/u/janis-berzins)
#### Post date: [December 3, 2015, 10:37pm UTC](https://forums.powershell.org/t/how-to-use-ps-cmdlets-in-a-dsc-resource-helper-functions/5302/4 "2015-12-03T22:37:24Z")

</div>

Sorted by running import-module when calling the helper function.

---

<div class="post-metadata">

### Author: ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)
#### Post date: [May 16, 2024, 9:17pm UTC](https://forums.powershell.org/t/how-to-use-ps-cmdlets-in-a-dsc-resource-helper-functions/5302/5 "2024-05-16T21:17:13Z")

</div>


