Search notes:

Examples for the PowerShell module Rene.wsb

These are a few examples for the PowerShell module Rene.wsb.

Open explorer

start-wsb -logonCommand 'explorer.exe C:\Users\WDAGUtilityAccount'
Github repository ps-module-wsb, path: /examples/open-explorer.ps1

Run multiple commands

start-wsb -visiblePsCommand 'write-host "temp = $env:temp" -fo green; write-host "this is red" -fo red'
Github repository ps-module-wsb, path: /examples/multiple-commands.ps1

Disable the clipboard

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
}
Github repository ps-module-wsb, path: /examples/disable-clipboard.ps1

Run a Powershell script

start-wsb -psScript $psScriptRoot\the-script-to-be-run.ps1
Github repository ps-module-wsb, path: /examples/script/run-the-script.ps1

The script to be executed

write-host 'success' -fo green

Start the sandbox with Notepad

Using the parameter -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 }
Github repository ps-module-wsb, path: /examples/with-notepad.ps1
Note: when -withNotepad is used, the parameters -psScript and -logonCommand have no effect.

Index