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 Get-DateRange { | |
Add-Type -AssemblyName System.Windows.Forms | |
$form = new-object Windows.Forms.Form | |
$form.text = "Calendar" | |
$form.Size = new-object Drawing.Size @(656,639) | |
# Make "Hidden" SelectButton to handle Enter Key | |
$btnSelect = new-object System.Windows.Forms.Button | |
$btnSelect.Size = "1,1" | |
$btnSelect.add_Click({ |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 whereEx { | |
[CmdletBinding()] | |
Param | |
( | |
[Parameter(ValueFromPipeline=$true)] | |
$InputObject, | |
[Parameter(Mandatory=$true, | |
Position=0)] | |
$predicateString |
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 Get-FileWCSynchronous{ | |
param( | |
[Parameter(Mandatory=$true)] | |
$url, | |
$destinationFolder="$env:USERPROFILE\Downloads", | |
[switch]$includeStats | |
) | |
$wc = New-Object Net.WebClient | |
$wc.UseDefaultCredentials = $true | |
$destination = Join-Path $destinationFolder ($url | Split-Path -Leaf) |
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
#Increase a number within a string by one | |
$data = 'XX3.txt', 'XX33.txt', 'XX333.txt' | |
$data | foreach{ | |
[RegEx]::Replace($_, '(\d{1,3})', {1+$args[0].Value}) | |
} | |
#Capitalize the second word within a sentence string | |
$script:counter = 0 | |
[regex]::Replace('this is a test','\w+', { | |
$script:counter++ | |
if ($counter -eq 2){ |
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
#https://datamarket.azure.com/account/keys | |
#Home -> My Account -> Account Keys: | |
#based on http://www.powershelladmin.com/wiki/Accessing_the_Bing_Search_API_v2_using_PowerShell | |
function Get-BingSearchResult($query){ | |
Add-Type -Assembly System.Web | |
$Key = 'YOURACCOUNTKEY' | |
$Base64KeyBytes = [byte[]] [Text.Encoding]::ASCII.GetBytes("ignored:$Key") | |
$Base64Key = [Convert]::ToBase64String($Base64KeyBytes) | |
$QueryString = '%27' + [Web.HttpUtility]::UrlEncode($query) + '%27' |
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 Get-FileBitsTransferAsynchronous{ | |
param( | |
[Parameter(Mandatory=$true)] | |
$url, | |
$destinationFolder="$env:USERPROFILE\Downloads", | |
[switch]$includeStats | |
) | |
$start = Get-Date | |
$job = Start-BitsTransfer -Source $url -Destination $destinationFolder -DisplayName 'Download' -Asynchronous | |
$destination = Join-Path $destinationFolder ($url | Split-Path -Leaf) |
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
[datetime]::ParseExact('08|12|2009 4:33 PM','dd|MM|yyyy h:m tt',$Null) | |
#returns Tuesday, December 8, 2009 4:33:00 PM on an English system |
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
$Title = "Title" | |
$Info = "Pick Something!" | |
$options = echo Option1 Option2 Option3 | |
$defaultchoice = 2 | |
$selected = $host.UI.PromptForChoice($Title , $Info , $Options, $defaultchoice) | |
$options[$selected] |
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 mySelect { | |
[CmdletBinding()] | |
param( | |
[Parameter(ValueFromPipeline=$true)] | |
[psobject]$InputObject, | |
[Parameter(Position=0)] | |
$Property | |
) | |
begin{ | |
#only if the property array contains a hashtable property |