concept powershell in category powershell
appears as: PowerShell,
PowerShell, powershell

This is an excerpt from Manning's book Windows PowerShell in Action, Third Edition.
PowerShell remoting from Linux to Windows works in a similar manner to Windows to Windows remoting. An example of a remoting session from a Linux machine to a Windows machine is shown in figure 5.
PowerShell help system
Listing 17.4. search.ps1: defining the file search behavior
Add-Type -Assembly PresentationCore,PresentationFrameWork 1 trap { break } $mode = [System.Threading.Thread]::CurrentThread.ApartmentState if ($mode -ne "STA") { $m = "This script can only be run when powershell is " + "started with the -sta switch." throw $m } function Add-PSScriptRoot ($file) 2 { $caller = Get-Variable -Value -Scope 1 MyInvocation $caller.MyCommand.Definition | Split-Path -Parent | Join-Path -Resolve -ChildPath $file } $xamlPath = Add-PSScriptRoot search.xaml $stream = [System.IO.StreamReader] $xamlpath 3 $form = [System.Windows.Markup.XamlReader]::Load( $stream.BaseStream) $stream.Close() $Path = $form.FindName("Path") 4 $Path.Text = $PWD $FileFilter = $form.FindName("FileFilter") 5 $FileFilter.Text = "*.ps1" $TextPattern = $form.FindName("TextPattern") $Recurse = $form.FindName("Recurse") $UseRegex = $form.FindName("UseRegex") 6 $UseRegex.IsChecked = $true $FirstOnly = $form.FindName("FirstOnly") $Run = $form.FindName("Run") 7 $Run.add_Click({ $form.DialogResult = $true $form.Close() }) $Show = $form.FindName("Show") $Show.add_Click({Write-Host (Get-CommandString)}) $Cancel = $form.FindName("Cancel") $Cancel.add_Click({$form.Close()}) function Get-CommandString 8 { function fixBool ($val) { '$' + $val } 9 "Get-ChildItem $($Path.Text) `` -Recurse: $(fixBool $Recurse.IsChecked) `` -Filter '$($FileFilter.Text)' | Select-String -SimpleMatch: (! $(fixBool $UseRegex.IsChecked)) `` -Pattern '$($TextPattern.Text)' `` -List: $(fixBool $FirstOnly.IsChecked)" } if ($form.ShowDialog()) 10 { $cmd = Get-CommandString Invoke-Expression $cmd }