full_path
stringlengths
31
232
filename
stringlengths
4
167
content
stringlengths
0
48.3M
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/WPK/Move-Control.ps1
Move-Control.ps1
function Move-Control { <# .Synopsis Moves a control to a location, and animates the transition .Description Moves a control to a fixed point on the screen, to another control's location, or to the location and size of the parent control. Also allows the control to be faded in ...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/WPK/Start-Animation.ps1
Start-Animation.ps1
function Start-Animation{ <# .Synopsis Starts animations on a property in any number of inputObjects .Description Starts animations on a property in any number of inputObjects .Example New-Window "Hello World" -SizeToContent WidthAndHeight -On_Loaded { $this ...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/WPK/Test-Descendent.ps1
Test-Descendent.ps1
None
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/WPK/ConvertTo-Xaml.ps1
ConvertTo-Xaml.ps1
function ConvertTo-Xaml { <# .Synopsis Attempts to coerce the text into XAML .Description Attempts to coerce the text into XAML .Example ConvertTo-Xaml "<Button Content='Click Me' />" .Parameter text The text to attempt to tr...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/WPK/Add-GridRow.ps1
Add-GridRow.ps1
function Add-GridRow { <# .Synopsis Adds a row to an existing grid .Description Adds a row to an existing grid, and optionally offsets everything past a certain row .Example Add-GridRow $grid -row Auto,Auto -index 2 .Parameter grid ...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/WPK/Set-DependencyProperty.ps1
Set-DependencyProperty.ps1
function Set-DependencyProperty { <# .Synopsis Sets the dependency properties on an object. .Description Sets the dependency properties on an object. Dependency properties are used in WPF to attach auxilliary information to an object that other UI components ...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/WPK/Get-HashtableAsObject.ps1
Get-HashtableAsObject.ps1
function Get-HashtableAsObject( [Parameter(ValueFromPipeline=$true)] [Hashtable]$hashtable ) { #.Synopsis # Turns a Hashtable into a PowerShell object #.Description # Creates a new object from a hashtable. #.Example # # Creates a new object with a property foo and t...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/WPK/ConvertFrom-TypeToScriptCmdlet.ps1
ConvertFrom-TypeToScriptCmdlet.ps1
function ConvertFrom-TypeToScriptCmdlet { <# .Synopsis Converts .NET Types into Windows PowerShell Script Cmdlets according to a number of rules. that have been added with Add-CodeGeneration rule .Description Converts .NET Types into Windows PowerShell Script Cmdlets ...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/WPK/Show-Window.ps1
Show-Window.ps1
function Show-Window { <# .Synopsis Show-Window shows a WPF control within a window, and is used by the -Show Parameter of all commands within WPK .Description Show-Window displays a control within a window and adds several resources to the window to make several scen...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/WPK/Set-Resource.ps1
Set-Resource.ps1
function Set-Resource { <# .Synopsis Sets a Resource that will be available across different handlers for a control. .Description Writing user interfaces effectively is about sharing information in between multiple controls. To do this, each control has a d...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/WPK/Get-CommandPlugin.ps1
Get-CommandPlugin.ps1
function Get-CommandPlugin { <# .Synopsis Finds all of the commands that have a signature similar to command .Description Searches all of the commands for a similar signature to a base command The signature of a command will be considered to...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/WPK/Get-PowerShellDataSource.ps1
Get-PowerShellDataSource.ps1
function Get-PowerShellDataSource { <# .Synopsis Gets a new PowerShell data source .Description Gets a new PowerShell data source. PowerShell data sources are used within a WPF application or WPK script to provide data from PowerShell to the UI asynchronously. ...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/WPK/Get-UIElementPosition.ps1
Get-UIElementPosition.ps1
function Get-UIElementPosition { <# .Synopsis Gets the screen position of the UI Element .Description Uses the TranslatePoint method to retrieve the position of one or more UI Elements relative to another UI Element. By default, the position is relative to the Window .Ex...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/WPK/Join-PowerShellCommandOutput.ps1
Join-PowerShellCommandOutput.ps1
function Join-PowerShellCommandOutput( [Parameter(ValueFromPipelineByPropertyName=$true)] [string]$commandName, [Parameter(ValueFromPipelineByPropertyName=$true)] [string]$uiElementName, [string]$targetProperty, [ScriptBlock]$updateScript, [Parameter(ValueFromPipelineByPropertyName=...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/WPK/Get-ChildControl.ps1
Get-ChildControl.ps1
function Get-ChildControl { <# .Synopsis Gets a Child UIElement anywhere in a visual tree .Description Gets a Child UIElement anywhere in a visual tree .Example $window | Get-ChildControl FooBar .Parameter name The name of the control to look for .Param...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/WPK/Test-Ancestor.ps1
Test-Ancestor.ps1
None
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/WPK/Register-PowerShellCommand.ps1
Register-PowerShellCommand.ps1
function Register-PowerShellCommand { <# .Synopsis Registers a PowerShell scriptblock command for use within a window .Description Registers a PowerShell scriptblock for use within a window. The command can be run registered for one time use, it can register anonymous...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/WPK/ConvertTo-ParameterMetaData.ps1
ConvertTo-ParameterMetaData.ps1
function ConvertTo-ParameterMetaData { <# .Synopsis Turns reflection information on a type into parameter metadata .Description Turns reflection information on a type into parameter metadata. Parameter metadata can be used to rapidly generate functions. The s...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/WPK/Remove-ChildControl.ps1
Remove-ChildControl.ps1
function Remove-ChildControl { <# .Synopsis Removes a Child from a parent control .Description Disconnects a child control from a parent control. .Parameter Control The control to remove .Parameter Parent The container the control is currently in. #> ...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/WPK/ConvertTo-DataTemplate.ps1
ConvertTo-DataTemplate.ps1
function ConvertTo-DataTemplate { <# .Synopsis Converts the UIElement to a data template .Description Converts the UIElement to a data template by stripping its resources, outputting the control as XAML, and enclosing within <DateTemplate> tags .E...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/WPK/Update-WPFJob.ps1
Update-WPFJob.ps1
function Update-WPFJob { <# .Synopsis Updates a running WPF Job by running a PowerShell script .Description Runs a PowerShell script within a WPF Job and returns the results. This enables two way communication with WPF Jobs. You can use the $Window variable and Get-Ch...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/WPK/Get-Resource.ps1
Get-Resource.ps1
function Get-Resource { <# .Synopsis Finds a Resource in a visual control or the controls parents .Description Retrieves a resource stored in the Resources property of a UIElement. If the UIElement does not contain the resource, the parent will be checked. If no more ...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/WPK/Close-Control.ps1
Close-Control.ps1
None
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/WPK/Start-WPFJob.ps1
Start-WPFJob.ps1
function Start-WPFJob { <# .Synopsis Starts a WPF Job to display a UI in the background .Description Starts a WPF Job to display a UI in the background. You can stop the job with the Stop-Job cmdlet, or by closing the window. You can run scripts within the window with...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/WPK/Add-ChildControl.ps1
Add-ChildControl.ps1
function Add-ChildControl { <# .Synopsis Adds a Child Control to a panel .Description Adds a Child Control to a panel .Example New-StackPanel -On_Loaded { New-Label "Hello" | Add-ChildControl -parent $this } .Parameter control The UI El...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/WPK/GeneratedControls/Winforms.ps1
Winforms.ps1
function New-ScrollableControl { <# .Description Creates a new System.Windows.Forms.ScrollableControl .Synopsis Creates a new System.Windows.Forms.ScrollableControl .Example New-ScrollableControl .Example New-ScrollableControl -OutputXaml .Pa...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/WPK/GeneratedControls/PresentationCore.ps1
PresentationCore.ps1
function New-DoubleIListConverter { <# .Description Creates a new System.Windows.Media.Converters.DoubleIListConverter .Synopsis Creates a new System.Windows.Media.Converters.DoubleIListConverter .Example New-DoubleIListConverter .Example New-Doub...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/WPK/GeneratedControls/WindowsFormsIntegration.ps1
WindowsFormsIntegration.ps1
function New-ElementHost { <# .Description Creates a new System.Windows.Forms.Integration.ElementHost .Synopsis Creates a new System.Windows.Forms.Integration.ElementHost .Example New-ElementHost .Example New-ElementHost -OutputXaml .Paramete...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/WPK/GeneratedControls/WindowsBase.ps1
WindowsBase.ps1
function New-FileFormatException { <# .Description Creates a new System.IO.FileFormatException .Synopsis Creates a new System.IO.FileFormatException .Example New-FileFormatException .Example New-FileFormatException -OutputXaml .Parameter Outp...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/WPK/GeneratedControls/PresentationFramework.ps1
PresentationFramework.ps1
function New-OpenFileDialog { <# .Description Creates a new Microsoft.Win32.OpenFileDialog .Synopsis Creates a new Microsoft.Win32.OpenFileDialog .Example New-OpenFileDialog .Example New-OpenFileDialog -OutputXaml .Parameter OutputXaml ...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/WPK/Rules/WPFCodeGenerationRules.ps1
WPFCodeGenerationRules.ps1
# Editing this file is not recommended. # This file contains a series of rules which will help convert the types WPF # interacts with the most to Script Cmdlets in PowerShell. The rules are processed # in the order that they appear Add-CodeGenerationRule -Filter { $_.Fullname -like "*Commands" } -Change {...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/WPK/Examples/DigitalClock.ps1
DigitalClock.ps1
New-Label -FontSize 24 -On_Loaded { Register-PowerShellCommand -scriptBlock { $window.Content.Content = (Get-Date | Out-String).Trim() } -run -in "0:0:0.5" } -Show
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/WPK/Examples/MutlitouchDraw.ps1
MutlitouchDraw.ps1
New-Window -WindowState Maximized -Resource @{ Styluses=@{} } -On_Loaded { $this | Enable-MultiTouch } -On_StylusDown { $styluses = $this.Resources.Styluses $origin = $_.GetPosition($this.Content) $color = 'Black', 'Pink', 'Red', 'Blue', 'Green', 'Orange','DarkRed', 'MidnightBlue',...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/WPK/Examples/ImportWinForms.ps1
ImportWinForms.ps1
Measure-Command { $controls = [windows.Forms.Control].Assembly.GetTypes() | ? { $_.IsPublic -and (-not $_.IsAbstract) -and $_.Fullname -notlike "*Internal*" -and ( $_.IsSubClassOf([windows.Forms.Control]) -or $_.IsSubclassOf([Windows.Forms.CommonDialog]) ) -and (-not (Get-Command -N...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/WPK/Examples/ListBoxSamples.ps1
ListBoxSamples.ps1
New-ListBox {1..100 } -MaxHeight 300 -show New-ListBox -SelectionMode Multiple {1..100 | Sort-Object -Descending} -MaxHeight 300 -show New-ListBox {1..100} -On_KeyDown { if ($_.Key -eq "Enter") { $window.Close() } } -show
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/WPK/Examples/EllipseAnimation.ps1
EllipseAnimation.ps1
New-Window -Width 200 -Height 200 { New-Ellipse -Fill Black -Width 200 -Height 100 -RenderTransform { New-RotateTransform -CenterX 75 -CenterY 50 } -On_Loaded { $da = New-DoubleAnimation -From 0 -To 360 -Duration ([Timespan]::FromMilliseconds(750)) -RepeatBehavior Forever Start-Ani...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/WPK/Examples/CmdletExample.ps1
CmdletExample.ps1
New-Grid -Columns 2 -Rows 5 { $script:Action = { $noun = $this.Parent | Get-ChildControl Noun | Select-Object -ExpandProperty Text $verb = $this.Parent | Get-ChildControl Verb | Select-Object -ExpandProperty Text $name = $this.Parent...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/WPK/Examples/MutlitouchImage.ps1
MutlitouchImage.ps1
New-Window -Background Black -WindowState Maximized -Resource @{ Styluses=@{} } -On_Loaded { $this | Enable-MultiTouch $c = 0 $path = 'C:\Users\Public\Videos\Sample Videos' #$path = "$env:UserProfile\Pictures" Get-ChildItem $path | Get-Random -Count 4 | For...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/WPK/Examples/AnimatedLinesFromCenter.ps1
AnimatedLinesFromCenter.ps1
New-Window -On_Loaded { $this | Enable-MultiTouch } -WindowStyle None -WindowState Maximized -On_StylusDown { $to = $_.GetPosition($this) $from = New-Object Windows.Point -Property @{ X = $this.ActualWidth / 2 Y = $this.ActualHeight / 2 } $xanimation = New-...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/WPK/Examples/ListView.ps1
ListView.ps1
New-ListView -Width 350 -Height 350 -DataBinding @{ ItemsSource = New-Binding -IsAsync -UpdateSourceTrigger PropertyChanged -Path Output } -View { New-GridView -AllowsColumnReorder -Columns { New-GridViewColumn "Name" New-GridViewColumn "Id" } } -DataContext { Get-PowerShellDat...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/WPK/Examples/flyin.ps1
flyin.ps1
New-Canvas -Width 640 -Height 480 -On_Loaded { $c = $this $duration = [Timespan]::FromMilliseconds(200) foreach ($n in 1..10) { $guid = [GUID]::NewGuid().ToString() $window.Resources.TemporaryControls."$guid" = $c $popupScript = [ScriptBlock]::Create(" `$contro...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/WPK/Examples/SkewAnimation.ps1
SkewAnimation.ps1
New-Window -Width 200 -Height 200 { New-Rectangle -Fill Black -Width 200 -Height 100 -RenderTransform { New-SkewTransform -AngleY 89 } -On_Loaded { $da = New-DoubleAnimation -From 89 -To 0 -Duration ([Timespan]::FromMilliseconds(750)) -RepeatBehavior Forever Start-Animation -InputOb...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/WPK/Examples/FlowDocument.ps1
FlowDocument.ps1
New-FlowDocumentReader -IsFindEnabled:$false -Document { New-FlowDocument { New-Paragraph -TextAlignment Right { New-Button -FontSize 20 "Add _Paragraph" -On_Click { $this.Parent.Parent.Parent.Blocks.Add( (New-Paragraph { "Hello World" }) ...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/WPK/Examples/DataTemplate.ps1
DataTemplate.ps1
New-ListBox -ItemsSource { Get-Process } -ItemTemplate { New-StackPanel -Orientation Horizontal -Children { New-Label -Name ProcessName -FontSize 14 New-Label -Name Id -FontSize 8 } | ConvertTo-DataTemplate -binding @{ "ProcessName.Content" = "ProcessName" "Id.Content" = "...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/WPK/Examples/Show-Module.ps1
Show-Module.ps1
New-Grid -Columns 3 -Rows 2 -Resource @{ 'Import-ModuleData' = { $modules = @(Get-Module) + @(Get-Module -ListAvailable) | Select-Object Name, Path, ExportedCommands -Unique | Sort-Object Name foreach ($m in $modules) { New-TreeViewItem -Header $m.Name -Da...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/WPK/Examples/canvasfromblend.ps1
canvasfromblend.ps1
$text = '<Canvas x:Name="Layer_1" Width="369.471" Height="368.253" Canvas.Left="0" Canvas.Top="0"> <Path x:Name="Path" Width="188.606" Height="83.13" Canvas.Left="180.869" Canvas.Top="104.77" Stretch="Fill" Data="F1 M 187.252,182.955C 265.978,183.089 344.703,183.223 364.3,163.457C 383.897,143.69 344.365,104.024 303....
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/WPK/Examples/Stopwatch.ps1
Stopwatch.ps1
New-Grid -FontSize 24 -Rows 2 -Columns 2 -On_Loaded { Register-PowerShellCommand -name UpdateClock -scriptBlock { $stopWatch = $window | Get-ChildControl StopWatch $stopWatch.Content = [Datetime]::Now - $stopWatch.Tag } } { New-Label -Name Stopwatc...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/WPK/Examples/RunCommand.ps1
RunCommand.ps1
New-Grid -Rows 'Auto', '1*', 'Auto' -Columns '1*', 'Auto' { New-TextBox -MinLines 1 -MinWidth 100 -Name Command -On_Loaded { Set-Resource "Command" $this -1 } New-Button "E_xecute" -Column 1 -MaxHeight 30 -On_Click { $Command = Get-Resource "Command" $output = Get-Resource "Ou...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/WPK/Examples/PowerShellDataSources.ps1
PowerShellDataSources.ps1
New-ListBox -MaxHeight 350 -DataContext { Get-PowerShellDataSource -Script { Get-Process | ForEach-Object { $_ ; Start-Sleep -Milliseconds 100 } } } -DataBinding @{ ItemsSource = New-Binding -IsAsync -UpdateSourceTrigger PropertyChanged -Path Output } -On_Loaded { Register-PowerShellComma...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/WPK/Examples/Gradient.ps1
Gradient.ps1
New-Canvas -Width 400 -Height 400 -Background { New-LinearGradientBrush -SpreadMethod Pad -StartPoint (New-Object Windows.Point 0, 0) -EndPoint (New-Object Windows.Point 0, .9) -GradientStops { New-GradientStop -Color "Red" -Offset .1 New-GradientStop -Color "White" -Offset .4 New-Gradi...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/WPK/Examples/AddGridRowExample.ps1
AddGridRowExample.ps1
New-Window -Width 640 -Height 480 { New-Grid -Rows 2 -Columns 2 -ShowGridLines { New-Button -Row 0 -Column 0 -On_Click { $addingRow = $true, $false | Get-Random if ($addingRow) { Add-GridRow $this.Parent -row 1 -index 0 } else { ...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/WPK/Examples/MoveControlExamples.ps1
MoveControlExamples.ps1
New-Canvas -Width 640 -Height 480 { 10..(Get-Random -Minimum 20 -Maximum 50) | ForEach-Object { New-Button "Click Me" ` -Opacity ((Get-Random -Minimum 75 -Maximum 100) / 100) ` -Top (Get-Random -Maximum 320) ` -Left (Get-Random -Maximum 240) ` -Width (...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/WPK/Examples/RichTextBoxAndCommands.ps1
RichTextBoxAndCommands.ps1
New-DockPanel -Width 400 { New-Menu -Dock Top { New-MenuItem "_File" { New-MenuItem -Name Foo -Command Open -CommandBindings { New-CommandBinding -Command { Get-ApplicationCommand -Open } -On_Executed { $rtb = Get-Resource "RichTextBox" ...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/WPK/Examples/SimpleDialog.ps1
SimpleDialog.ps1
New-Grid -Rows 4 { New-Label "Please Enter Your Name" New-TextBox -Name YourName -Row 1 -On_PreviewKeyDown { if ($_.Key -eq "Enter") { $_.Handled = $true Invoke-ControlEvent -parent $window -control "Done" -event "Click" } } New-StackPanel -Ro...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/WPK/Examples/MixingArgumentFormats.ps1
MixingArgumentFormats.ps1
# This demonstrates the different ways you can specify values for a command with WPK. # You can either use a literal value, a script block, or XML. New-Window { New-Canvas -RenderTransform '<TransformGroup> <ScaleTransform ScaleX="2" ScaleY="2"/> <SkewTransform AngleX="0" AngleY="0"/> <RotateTransfor...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/WPK/Examples/CanvasFromDesign.ps1
CanvasFromDesign.ps1
New-Window { @" <Canvas x:Name="Layer_1" Width="452.568" Height="378.579" Canvas.Left="0" Canvas.Top="0"> <Path x:Name="Path" Width="215.704" Height="248.919" Canvas.Left="0" Canvas.Top="0" Stretch="Fill" StrokeLineJoin="Round" Stroke="#FF000000" Fill="#FFFFFFFF" Data="F1 M 215.204,126.46L 0.5,2.50008L 0.5,250.41...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/SQLIse/TabExpansion.ps1
TabExpansion.ps1
function TabExpansion { param($line, $lastWord) function Write-Members ($sep='.') { Invoke-Expression ('$_val=' + $_expression) $_method = [Management.Automation.PSMemberTypes] ` 'Method,CodeMethod,ScriptMethod,ParameterizedProperty' if ($sep -eq '.') { ...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/SQLIse/Show-DbObjectList.ps1
Show-DbObjectList.ps1
function Show-DbObjectList($ds) { New-Window { @' <ScrollViewer> <ScrollViewer.Resources> <DataTemplate x:Key = "ColumnTemplate"> <TreeViewItem Header="{Binding Column}" /> </DataTemplate> <DataTemplate x:Key = "ParameterTemplate"> ...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/SQLIse/Get-DbObjectList.ps1
Get-DbObjectList.ps1
function Get-DbObjectList { $db = @" SELECT db_name() AS 'Database'; "@ $pk = @" SELECT kcu.TABLE_SCHEMA + '.' + kcu.TABLE_NAME AS 'Table', kcu.COLUMN_NAME FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS AS tc JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS kcu ON kcu.CONSTRAINT_SCHEMA = tc.CONSTRAINT_SCHEMA AN...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/SQLIse/Expand-String.ps1
Expand-String.ps1
param([String]$text) $returnedText = "" foreach ( $line in $text -split [System.Environment]::NewLine ) { if ( $line.length -gt 0) { if ($line -match '(\$(\w+))') #{ $line = $line -replace '(\$(\w+))',(get-variable $matches[2] -Scope Global -Value...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/SQLIse/Library-StringCrypto.ps1
Library-StringCrypto.ps1
####################### function Protect-String { param([string]$InputString) $secure = ConvertTo-SecureString $InputString -asPlainText -force $export = $secure | ConvertFrom-SecureString write-output $export } #Protect-String ####################### function UnProtect-String { par...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/SQLIse/Library-UserStore.ps1
Library-UserStore.ps1
####################### function Test-UserStore { param([string]$fileName,[string]$dirName) $userStore = [System.IO.IsolatedStorage.IsolatedStorageFile]::GetUserStoreForAssembly() if ($userStore.GetDirectoryNames($dirName)) { if ($userStore.GetFileNames("$dirName\$fileName")) ...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/SQLIse/Show-ConnectionManager.ps1
Show-ConnectionManager.ps1
function Show-ConnectionManager () { $ui = New-Grid -Columns 3 -Rows 7 -Name ConnectionGrid { $ComboBoxStyle = @{ Height = 30 Width = 100 Margin = 5 FontSize = 12 IsSynchronizedWithCurrentItem =...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/SQLIse/Get-ConnectionInfo.ps1
Get-ConnectionInfo.ps1
function Get-ConnectionInfo { param($bitmap) $ui = New-Grid -Columns 2 -Rows 8 -width 428 -height 324 ` -Children { $script:Action = { $connName = $window | Get-ChildControl ConnectionName $server = $window | Get-ChildControl Server $database = $window | Get-ChildControl Database ...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/SQLIse/Show-TableBrowser.ps1
Show-TableBrowser.ps1
function Show-TableBrowser ($resource) { New-Grid -Rows 1 -Columns 2 { New-ListView -Column 0 -Row 1 -Name TableView -View { New-GridView -AllowsColumnReorder -Columns { New-GridViewColumn "TABLE_SCHEMA" New-GridViewColumn "TABLE_NAME" } }...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/SQLIse/ConvertFrom-Xml.ps1
ConvertFrom-Xml.ps1
function ConvertFrom-Xml($XML) { foreach ($Object in @($XML.Objects.Object)) { $PSObject = New-Object PSObject foreach ($Property in @($Object.Property)) { $PSObject | Add-Member NoteProperty -Name $Property.Name -Value $Property.InnerText } $PSObject } }
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/SQLIse/Get-TableAlias.ps1
Get-TableAlias.ps1
###################### function Resolve-TableAlias { $sqlList = $psise.CurrentFile.Editor.Text -split '\n' $obj = '[\w]+|\"(?:[^\"]|\"\")+\"|\[(?:[^\]]|\]\])+\]' $re = "($obj)\.($obj)?\.($obj)(\s+.*$)?|(?:($obj)\.)?($obj)(\s+.*$)?" $from = '(\bFROM\b|\bJOIN\b|\bUPDATE\b|\bINSERT\b(?:\s+IN...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/SQLIse/Get-TabObjectList.ps1
Get-TabObjectList.ps1
function Get-TabObjectList { $db = @" SELECT db_name() AS 'Database'; "@ $col = @" SELECT TABLE_CATALOG AS 'Database', TABLE_SCHEMA AS 'Schema', TABLE_NAME AS 'Object', COLUMN_NAME AS 'Column' FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME NOT IN ('dtproperties','sysdiagrams') AND OBJECTPROPERTY(OBJ...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/SQLIse/Invoke-Coalesce.ps1
Invoke-Coalesce.ps1
####################### function Invoke-Coalesce { param ($expression1, $expression2) if ($expression1) { $expression1 } else { $expression2 } } #Invoke-Coalesce
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/SQLIse/defaultopts.ps1
defaultopts.ps1
# --------------------------------------------------------------------------- ### <Script> ### <Author> ### Chad Miller ### </Author> ### <Description> ### This file is used to set options default options for SQLIse ### </Description> ### </Script> # -----------------------------------------------------------...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/SQLIse/ConvertTo-StringData.ps1
ConvertTo-StringData.ps1
function ConvertTo-StringData { Begin { $string = "@{`n" function Expand-Value { param($value) if ($value -ne $null) { switch ($value.GetType().Name) { 'String' { "`"$value`"" } ...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/SQLIse/Set-Options.ps1
Set-Options.ps1
function Set-Options { param() New-Grid -Columns 3 -Rows 25 -width 600 -height 600 { $script:Action = { $results = $window | Get-ChildControl | where { $_.GroupName -eq "Results" -and $_.IsChecked } | foreach { $_.Content } $options.Results = $results $OutputVariable = $window | Ge...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/SQLIse/Switch-CommentOrText.ps1
Switch-CommentOrText.ps1
#NOTE: This function is excerpted from http://code.msdn.microsoft.com/PowerShellPack with minor changes to support SQLIse function Switch-CommentOrText { <# .Synopsis Switches between commented and uncommented text .Description Takes a block of text. Uncomments lines that are commente...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/SQLIse/Switch-SelectedCommentOrText.ps1
Switch-SelectedCommentOrText.ps1
#NOTE: This function is excerpted from http://code.msdn.microsoft.com/PowerShellPack with minor changes to support SQLIse function Switch-SelectedCommentOrText { <# .Synopsis Toggles Comments on the selected text .Description Toggles comments on the currently selected text. Co...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/posh-git/TortoiseGit.ps1
TortoiseGit.ps1
# TortoiseGit $Global:TortoiseGitSettings = new-object PSObject -Property @{ TortoiseGitPath = "C:\Program Files\TortoiseGit\bin\TortoiseProc.exe" } function tgit { if($args) { if($args[0] -eq "help") { # Replace the built-in help behaviour with just a list of commands $tortoiseGitComm...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/posh-git/CheckVersion.ps1
CheckVersion.ps1
$version = git --version 2> $null if($version -notlike 'git version 1.7.*.msysgit.*') { Write-Warning "posh-git requires msysgit version 1.7. You have $version." $false } else { $true }
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/posh-git/Utils.ps1
Utils.ps1
# General Utility Functions function Coalesce-Args { $result = $null foreach($arg in $args) { if ($arg -is [ScriptBlock]) { $result = & $arg } else { $result = $arg } if ($result) { break } } $result } Set-Alias ?? Coalesce-Args -F...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/posh-git/GitPrompt.ps1
GitPrompt.ps1
# Inspired by Mark Embling # http://www.markembling.info/view/my-ideal-powershell-prompt-with-git-integration $global:GitPromptSettings = New-Object PSObject -Property @{ DefaultForegroundColor = $Host.UI.RawUI.ForegroundColor BeforeText = ' [' BeforeForegroundColor = [Console...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/posh-git/GitUtils.ps1
GitUtils.ps1
# Inspired by Mark Embling # http://www.markembling.info/view/my-ideal-powershell-prompt-with-git-integration function Get-GitDirectory { Get-LocalOrParentPath .git } function Get-GitBranch($gitDir = $(Get-GitDirectory), [Diagnostics.Stopwatch]$sw) { if ($gitDir) { dbg 'Finding branch' $sw ...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/posh-git/profile.example.ps1
profile.example.ps1
Push-Location (Split-Path -Path $MyInvocation.MyCommand.Definition -Parent) # Load posh-git module from current directory Import-Module .\posh-git # If module is installed in a default location ($env:PSModulePath), # use this instead (see about_Modules for more information): # Import-Module posh-git # Set...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/posh-git/install.ps1
install.ps1
param([switch]$WhatIf = $false) if($PSVersionTable.PSVersion.Major -lt 2) { Write-Warning "posh-git requires PowerShell 2.0 or better; you have version $($Host.Version)." return } if(!(Get-Command git -ErrorAction SilentlyContinue)) { Write-Warning 'Could not find git command. Please create a git ...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/posh-git/GitTabExpansion.ps1
GitTabExpansion.ps1
# Initial implementation by Jeremy Skinner # http://www.jeremyskinner.co.uk/2010/03/07/using-git-with-windows-powershell/ $global:GitTabSettings = New-Object PSObject -Property @{ AllCommands = $false } $global:ops = @{ remote = 'add','rename','rm','set-head','show','prune','update' stash = 'list...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/posh-hg/HgUtils.ps1
HgUtils.ps1
function isHgDirectory() { if(test-path ".hg") { return $true; } if(test-path ".git") { return $false; #short circuit if git repo } # Test within parent dirs $checkIn = (Get-Item .).parent while ($checkIn -ne $NULL) { $pathToTest = $checkIn.fullname + '/.hg' if ((Tes...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/posh-hg/HgTabExpansion.ps1
HgTabExpansion.ps1
$script:hgCommands = @() function HgTabExpansion($lastBlock) { switch -regex ($lastBlock) { #handles hgtk help <cmd> #handles hgtk <cmd> 'thg (help )?(\S*)$' { thgCommands($matches[2]); } #handles hg update <branch name> #handles hg merge <branch name> 'hg (u...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/posh-hg/HgPrompt.ps1
HgPrompt.ps1
# For backwards compatibility $global:HgPromptSettings = $global:PoshHgSettings function Write-HgStatus($status = (get-hgStatus)) { if ($status) { $s = $global:PoshHgSettings $branchFg = $s.BranchForegroundColor $branchBg = $s.BranchBackgroundColor if($sta...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/posh-hg/profile.example.ps1
profile.example.ps1
Push-Location (Split-Path -Path $MyInvocation.MyCommand.Definition -Parent) # Load posh-hg module from current directory Import-Module .\posh-hg # If module is installed in a default location ($env:PSModulePath), # use this instead (see about_Modules for more information): # Import-Module posh-hg # Set up...
PowerShellCorpus/Github/legigor_WindowsPowerShell/AllModules/posh-hg/Settings.ps1
Settings.ps1
$global:PoshHgSettings = New-Object PSObject -Property @{ #Before prompt BeforeText = ' [' BeforeForegroundColor = [ConsoleColor]::Yellow BeforeBackgroundColor = $Host.UI.RawUI.BackgroundColor #After prompt AfterText = ']' AfterForegroundCo...
PowerShellCorpus/Github/legigor_WindowsPowerShell/LastProfile/profile.ps1
profile.ps1
. (Resolve-Path ~/Documents/WindowsPowershell/prompt.ps1) rm alias:curl $prj = 'C:\Projects' $nvt = 'C:\Projects\Nventree' $nvtJobbersScripts = 'C:\Projects\nventree\Enviroment\Jobbers\' Write-Host "Run manually: ipmo pscx"
PowerShellCorpus/Github/legigor_WindowsPowerShell/LastProfile/hgutils.ps1
hgutils.ps1
# Mercurial (hg) functions # Kornelije Sajler (http://learnaholic.me) # Adopted from Git version of: # Mark Embling (http://www.markembling.info/) # You can clone it by # hg clone https://xajler@bitbucket.org/xajler/powershell-prompt-for-mercurial/ # And find source here: # http://bitbucket.org/xajler/powersh...
PowerShellCorpus/Github/legigor_WindowsPowerShell/LastProfile/Microsoft.PowerShell_profile.ps1
Microsoft.PowerShell_profile.ps1
Import-Module PSReadLine
PowerShellCorpus/Github/legigor_WindowsPowerShell/LastProfile/gitutils.ps1
gitutils.ps1
# Git functions # Mark Embling (http://www.markembling.info/) # Is the current directory a git repository/working copy? function isCurrentDirectoryGitRepository { if ((Test-Path ".git") -eq $TRUE) { return $TRUE } # Test within parent dirs $checkIn = (Get-Item .).parent whil...
PowerShellCorpus/Github/legigor_WindowsPowerShell/LastProfile/Invoke-Locate.ps1
Invoke-Locate.ps1
<# .SYNOPSIS This script was made in the spirit of (Linux/Unix) GNU findutils' locate. "locate" and "updatedb" aliases are automatically created. .DESCRIPTION While the name of this script is Invoke-Locate, it actually creates two persistent aliases: locate and updatedb. A fresh index is automatical...
PowerShellCorpus/Github/legigor_WindowsPowerShell/LastProfile/prompt.ps1
prompt.ps1
. (Resolve-Path ~/Documents/WindowsPowershell/gitutils.ps1) . (Resolve-Path ~/Documents/WindowsPowershell/hgutils.ps1) . (Resolve-Path ~/Documents/WindowsPowershell/svnutils.ps1) $Host.UI.RawUI.ForegroundColor = "White" function prompt { # $path = "" $path = $pwd # $pathbits = ([string]$pwd).repl...
PowerShellCorpus/Github/legigor_WindowsPowerShell/LastProfile/svnutils.ps1
svnutils.ps1
function isCurrentDirectorySvn { if ((Test-Path ".svn") -eq $TRUE) { return $TRUE } # Test within parent dirs $checkIn = (Get-Item .).parent while ($checkIn -ne $NULL) { $pathToTest = $checkIn.fullname + '/.hg' if ((Test-Path $pathToTest) -eq $TRUE) { ...
PowerShellCorpus/Github/legigor_WindowsPowerShell/Modules/pscx/Pscx.UserPreferences.ps1
Pscx.UserPreferences.ps1
# --------------------------------------------------------------------------- # You can override individual preferences by passing a hashtable with just those # preference defined as shown below: # # Import-Module Pscx -arg @{ModulesToImport = @{Prompt = $true}} # # Any value not specified will be retrieved f...
PowerShellCorpus/Github/legigor_WindowsPowerShell/Modules/pscx/Modules/Prompt/Themes/Modern.ps1
Modern.ps1
# --------------------------------------------------------------------------- # Author: Keith Hill # Desc: Prompt, colors and host window title updates suited to UAC enabled # Windows Vista and Windows 7. Elevated (admin) prompts are easy # distinguish from non-elevated prompts. # Date: Nov 07...
PowerShellCorpus/Github/legigor_WindowsPowerShell/Modules/pscx/Modules/Prompt/Themes/WinXP.ps1
WinXP.ps1
# --------------------------------------------------------------------------- # Author: Keith Hill # Desc: Prompt, colors and host window title updates suited to Windows XP # where folks tend to run with adminstrator privileges all the time. # Date: Nov 07, 2009 # Site: http://pscx.codeplex.com # Us...
PowerShellCorpus/Github/legigor_WindowsPowerShell/Modules/pscx/Modules/Prompt/Themes/Jachym.ps1
Jachym.ps1
# --------------------------------------------------------------------------- # Author: Jachymko # Desc: Jachym's prompt, colors and host window title updates. # Date: Nov 07, 2009 # Site: http://pscx.codeplex.com # Usage: In your options hashtable place the following setting: # # PromptTheme = 'J...
PowerShellCorpus/Github/legigor_WindowsPowerShell/Modules/PSReadLine/SamplePSReadlineProfile.ps1
SamplePSReadlineProfile.ps1
# This is an example profile for PSReadline. # # This is roughly what I use so there is some emphasis on emacs bindings, # but most of these bindings make sense in Windows mode as well. Import-Module PSReadLine Set-PSReadLineOption -EditMode Emacs # Searching for commands with up/down arrow is really hand...
PowerShellCorpus/Github/legigor_WindowsPowerShell/Modules/posh-git/TortoiseGit.ps1
TortoiseGit.ps1
# TortoiseGit function private:Get-TortoiseGitPath { if ((Test-Path "C:\Program Files\TortoiseGit\bin\TortoiseGitProc.exe") -eq $true) { # TortoiseGit 1.8.0 renamed TortoiseProc to TortoiseGitProc. return "C:\Program Files\TortoiseGit\bin\TortoiseGitProc.exe" } return "C:\Program Files\Tortoise...