resource "null_resource" "server1" { provisioner "remote-exec" { inline = [ "powershell.exe $output = 'party' | Write-host"
]
null_resource.server1 (remote-exec): C:\Users\Administrator>powershell.exe $output = 'party' | Write-hostnull_resource.server1 (remote-exec): 'Write-host' is not recognized as an internal or external command,null_resource.server1 (remote-exec): operable program or batch file.
resource "null_resource" "server1" { provisioner "remote-exec" { inline = [
"powershell.exe \"$output = 'party' | Write-host\""
]
## In my .bash_profile or .bashrc
powershell () { DOCKER_RUN="docker run --rm --name powershell -it" DOCKER_IMAGE="centos/powershell" DOCKER_COMMAND="/usr/bin/powershell"
## Check permissions on Docker socket and fix if necessary if [[ ! -w /var/run/docker.sock ]]; then sudo setfacl -m u:jyoung:rw /var/run/docker.sock fi
## Make sure Powershell image is installed if [[ "$( docker images | grep -i powershell &>/dev/null; echo $? )" != "0" ]]; then printf "Pulling powershell image for use...\n" docker pull "${DOCKER_IMAGE}" &>/dev/null fi
## If we passed arguments, parse them, and if necessary, mount in the directory of the script we're trying to execute. if [[ "$#" > 0 ]]; then ARGS="$@" while [[ "$#" > 0 ]]; do if [[ "$1" == *".ps1"* ]]; then CURRENT_DIR=$( dirname $1 ) fi if [[ "$1" == *".psm1"* ]]; then CURRENT_DIR=$( dirname $1 ) fi shift done if [[ -n "${CURRENT_DIR}" ]]; then ${DOCKER_RUN} -v ${CURRENT_DIR}:/opt/powershell_volume:rw -w /opt/powershell_volume ${DOCKER_IMAGE} ${DOCKER_COMMAND} ${ARGS} else ${DOCKER_RUN} ${DOCKER_IMAGE} ${DOCKER_COMMAND} ${ARGS} fi else ${DOCKER_RUN} ${DOCKER_IMAGE} ${DOCKER_COMMAND} fi}
powershell get-host
Name : ConsoleHostVersion : 6.0.0InstanceId : bf28d67b-5c9d-48f8-a8d8-cd8521d6be31UI : System.Management.Automation.Internal.Host.InternalHostUserInterfaceCurrentCulture : CurrentUICulture : PrivateData : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxyDebuggerEnabled : TrueIsRunspacePushed : FalseRunspace : System.Management.Automation.Runspaces.LocalRunspace
$ powershell "\$output = 'party' | Write-Host"party