Skip to content

Instantly share code, notes, and snippets.

@mikepfeiffer
Created September 18, 2019 18:16
Show Gist options
  • Save mikepfeiffer/9ff8a952088de4f03c069fdb5447ec0d to your computer and use it in GitHub Desktop.
Save mikepfeiffer/9ff8a952088de4f03c069fdb5447ec0d to your computer and use it in GitHub Desktop.
Demo that shows how to use a utility function inside a PS Module
#private function
function new-baseEncode ($pat) {
$encoded = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes((":{0}" -f $pat)))
Write-Output $encoded
}
#public function
function New-EncodedMessage ($name, $data) {
$encoded = new-baseEncode $data
Write-Output @{
Name = $name
EncodedMessage = $encoded
}
}
#making the public function visible to module consumers
Export-ModuleMember New-EncodedMessage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment