Skip to content

Instantly share code, notes, and snippets.

View cdhunt's full-sized avatar

Chris Hunt cdhunt

View GitHub Profile
function New-Array {,$args}
PS C:\> Start-PSNode -Server http://localhost:9092/ -AuthenticationType IntegratedWindowsAuthentication -Command {
Get-Process | Select-Object Handle, WorkingSet, Id, Name, UserProcessorTime | ConvertTo-Json
}
PS C:\> Get-Web "http://localhost:9092" -AsJson
PS C:\> Get-Web -Url http://www.youtube.com/watch?v=xPRC3EDR_GU -AsMicrodata -ItemType http://schema.org/VideoObject | Export-PSData .\PipeworksQuickstart.video.psd1
@cdhunt
cdhunt / Posh2013_Event5
Created May 30, 2013 00:35
Second attempt at Event 5 based on what I learned from feedback and judging other scripts.
function Select-UniqueClientIP {
[CmdletBinding(SupportsPaging,DefaultParameterSetName="IPv4")]
[OutputType([System.String[]])]
param(
[Parameter(Position=0,Mandatory,ValueFromPipeline,ValueFromPipeLineByPropertyName)]
[ValidateNotNullOrEmpty()]
[Alias("FullName")]
[string[]]
$Path,
@cdhunt
cdhunt / Get-CredentialFromWindowsCredentialManager.ps1
Last active June 1, 2023 23:48 — forked from toburger/Get-CredentialFromWindowsCredentialManager.ps1
Gets a PowerShell Credential [PSCredential] from the Windows Credential Manager. This only works for Generic Credentials.
<#
.SYNOPSIS
Gets a PowerShell Credential (PSCredential) from the Windows Credential Manager
.DESCRIPTION
This module will return a [PSCredential] object from a credential stored in Windows Credential Manager. The
Get-StoredCredential function can only access Generic Credentials.
Alias: GSC
@cdhunt
cdhunt / APIExample
Created July 29, 2013 13:20
Example of marrying REST API and Windows COM API through Powershell.
function Out-Speech($text) {
$speechy = New-Object –ComObject SAPI.SPVoice;
$text
$voices = $speechy.GetVoices();
foreach ($voice in $voices) {
$voice.GetDescription();
$speechy.Voice = $voice;
$speechy.Speak($text);
}
}
@cdhunt
cdhunt / Get-NetworkHostList
Created January 13, 2014 14:13
Part of 2014 Scripting Games Practice Event
<#
.Synopsis
Return an array of IP Addresses
.DESCRIPTION
Return an array of System.Net.IPAddress objects from a string in the form 10.10.10.0/24.
.EXAMPLE
Return an array of usable IP addresses given a subnet.
PS C:\> $IPs = Get-NetworkHostList 192.168.7.0/24
PS C:\> $IPs[0].IPAddressToString
Import-Module PModule.psm1
$Credential = Get-Credential
$ips = Get-NetworkHostList 10.81.60.0/24
$list = $ips[(70..75)]
$c = 0
Foreach ($computer in $list)
{
[bool]$alive = $false
Write-Progress -Activity "Finding available hosts" -CurrentOperation "Testing" -Status $computer -PercentComplete (($c++/$list.count)*100)
@cdhunt
cdhunt / powerlambda
Last active August 29, 2015 13:57
Trying to create a variable containing a lambda expression
# Trying to call ListByNameFiltered from
# http://www.orthogonal.com.au/computers/simpledb/index.htm
# (input parameters) => expression
# (id) => { return id == 1234; }
[System.Reflection.Assembly]::LoadWithPartialName("System.Linq.Expressions")
if ( [string]::IsNullOrEmpty([psobject].Assembly.GetType("System.Management.Automation.TypeAccelerators")::get["Expression"]) )
{