This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Where-Object2 { | |
[CmdletBinding(DefaultParameterSetName='None')] | |
param( | |
[Parameter(ValueFromPipeline=$true)] | |
[psobject] | |
${InputObject}, | |
[Parameter(ParameterSetName='ScriptBlockSet', Mandatory=$true, Position=0)] | |
[scriptblock] | |
${FilterScript}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param | |
( | |
[Parameter(Mandatory,Position=1)] | |
[ValidateSet('CimMethod','Wdac','CimCmdletAdapter')] | |
$Method, | |
[Parameter(Mandatory,Position=2)] | |
[ValidateSet('64-bit','32-bit')] | |
$Platform | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get | |
Invoke-CimMethod -ClassName MSFT_OdbcDsnTask ` | |
-Namespace ROOT\Microsoft\Windows\Wdac ` | |
-MethodName 'Get' ` | |
-Arguments @{ | |
Name = $Name | |
DsnType = [string]$DsnType | |
Platform = $Platform | |
DriverName = $DriverName | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get | |
Invoke-CimMethod -ClassName MSFT_OdbcDsnTask ` | |
-Namespace ROOT\Microsoft\Windows\Wdac ` | |
-MethodName 'Get' ` | |
-Arguments @{ | |
Name = $Name | |
DsnType = [string]$DsnType | |
Platform = $Platform | |
DriverName = $DriverName | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Globalization; | |
using System.Management.Automation.Host; | |
namespace ProgressBarShim | |
{ | |
public class Host : PSHost | |
{ | |
private readonly PSHost PSHost; | |
private readonly HostUI HostUI; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Import-CliXml .\progress.xml | | |
% { | |
Write-Progress -Activity $_.Activity ` | |
-Status $_.StatusDescription ` | |
-Id $_.ActivityId ` | |
-CurrentOperation $_.CurrentOperation ` | |
-ParentId $_.ParentActivityId ` | |
-PercentComplete $_.PercentComplete ` | |
-SecondsRemaining $_.SecondsRemaining ` | |
-Completed:(@{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Get-OdbcDriver | | |
% { | |
$id = [guid]::NewGuid().Guid.Split('-')[0] | |
$name = $_.Name | |
try { | |
Invoke-CimMethod -ClassName MSFT_OdbcDsnTask ` | |
-Namespace ROOT\Microsoft\Windows\Wdac ` | |
-MethodName 'Add' ` | |
-Arguments @{ | |
Name = "test_$id" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Beforehand { | |
param( | |
[Parameter(Mandatory,ValueFromPipeline)] | |
$InputObject, | |
[Parameter(Mandatory,Position=1)] | |
[scriptblock] | |
$ScriptBlock | |
) | |
begin { . $ScriptBlock } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# All this C# is to synthesize a signal that corresponds to when a runspace is | |
# ready to be used. | |
# see also PowerShell/PowerShell#7034 | |
Add-Type ' | |
using System.Management.Automation; | |
using System.Management.Automation.Runspaces; | |
using System.Threading.Tasks; | |
using System.Collections.Concurrent; | |
using System.Linq; |
NewerOlder