I have a Pester test setup to test out one function within a .psm1 file. The function is very simple and pretty much adds to an existing cmdlet so that the PS code is more clean.

function Get-Datetime {
Get-Date -Format "MM.dd.yyyy:hh.mm.ss"
}
function Add-RabbitMQContent {
param
(
[string] $Path = "C:\predefinedlocation",
[Parameter(Mandatory=$true)] [string] $Value
)
Add-Content -Path $Path -Value "$(Get-DateTime) $Value"
}
#Example of when I am using the function. I like that I do not have to specify the location, but I can if I choose to and the #value will also write out the date time next to it like a log file.
Add-RabbitMQContent -Value "Exiting program!"

My Pester Test fails at using the "Add-RabbitMQContent" function noted in code below. If I attempt to pass a local directory or use the $TestDrive\ location it does not work. Any thoughts on why?

The Setup is not a self-made function. It is a cmdlet to add files to your TestDrive. So I cannot paste URL link in this post but here is code you can find in the Pester project on Github using "Setup."

OMG! Such a simple solution. I have been looking at my Pester testing all day. I should have walked away for a bit. I did not catch that. Thank you, Adam. I just this to my test and it worked successfully.