Rene.wsb. start-wsb -logonCommand 'explorer.exe C:\Users\WDAGUtilityAccount'
start-wsb -visiblePsCommand 'write-host "temp = $env:temp" -fo green; write-host "this is red" -fo red'
set-clipboard -value 'This value was copied to the clipboard in the host.'
start-wsb -disableClipboardRedirection -visiblePsCommand 'write-host (get-clipboard); set-clipboard -value "This value was copied to the clipboard in the sandbox."; read-host "Press any key to shutdown sandbox"; shutdown -s -t 0'
# start-wsb -visiblePsCommand 'write-host (get-clipboard); set-clipboard -value "This value was copied to the clipboard in the sandbox."; read-host "Press any key to shutdown sandbox"; shutdown -s -t 0'
while (-not (get-process WindowsSandboxClient -ea ignore)) {
#
# Wait until Sandbox is minimally started
#
start-sleep 1
}
while (get-process WindowsSandboxClient -ea ignore) {
#
# Wait until Sandbox is terminated
#
write-host (get-clipboard)
start-sleep 1
}
start-wsb -psScript $psScriptRoot\the-script-to-be-run.ps1
write-host 'success' -fo green
-withNotepad copies the host's notepad.exe to the sandbox's C:\Windows\System32 directory so that notepad can be run in the sandbox (see also No Notepad in Windows Sandbox). start-wsb -withNotepad `
-mappedFolders @{hostFolder = "$home\Downloads"; sandboxFolder = "c:\host\downloads"; readonly = $true },
@{hostFolder = "$home\Documents"; sandboxFolder = "c:\host\documents"; readonly = $false }
-withNotepad is used, the parameters -psScript and -logonCommand have no effect.