Skip to content

Instantly share code, notes, and snippets.

@BenjaminArmstrong
Created September 16, 2016 17:38
Show Gist options
  • Save BenjaminArmstrong/d36f5e6980a0b8ad2093eebb7106b467 to your computer and use it in GitHub Desktop.
Save BenjaminArmstrong/d36f5e6980a0b8ad2093eebb7106b467 to your computer and use it in GitHub Desktop.
PowerShell Direct Tips - Functions
function Logger {
# Do pretty logging of information
}
function cleanupFile {
# Do some repetitive file manipulation
}
function PrepVM {
# Setup things inside a VM
}
$FunctionDefs = "function PrepVM { ${function:PrepVM} }; function cleanupFile { ${function:cleanupFile} }; function logger { ${function:logger} }"
Invoke-Command -VMName "Test" {
. ([ScriptBlock]::Create($Using:FunctionDefs))
PrepVM
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment