Skip to content

Instantly share code, notes, and snippets.

View gravejester's full-sized avatar

Øyvind Kallstad gravejester

View GitHub Profile
@gravejester
gravejester / Get-WebFile.ps1
Created October 7, 2014 11:24
Download a file from the internet.
function Get-WebFile {
<#
.SYNOPSIS
Download a file from the internet.
.DESCRIPTION
Download a file from the internet.
.PARAMETER Url
URL of file being downloaded
@gravejester
gravejester / Write-PluralString.ps1
Created October 8, 2014 13:39
Write string with built-in handling of plural-s for variable integer.
function Write-PluralString{
<#
.SYNOPSIS
Write string with built-in handling of plural-s for variable integer.
.DESCRIPTION
Write string with built-in handling of plural-s for variable integer.
.EXAMPLE
Write-PluralString "$($computer): " $num 'file' 'processed'
@gravejester
gravejester / ConvertTo-DataTable.ps1
Last active September 5, 2023 11:31
ConvertTo-DataTable
function ConvertTo-DataTable {
<#
.SYNOPSIS
Convert regular PowerShell objects to a DataTable object.
.DESCRIPTION
Convert regular PowerShell objects to a DataTable object.
.EXAMPLE
$myDataTable = $myObject | ConvertTo-DataTable
@gravejester
gravejester / Test-Connection.ps1
Created October 13, 2014 08:55
Test-Connection Proxy Function adding Resolve parameter
function Test-Connection {
[CmdletBinding(DefaultParameterSetName='Default', HelpUri='http://go.microsoft.com/fwlink/?LinkID=135266', RemotingCapability='OwnedByCommand')]
param(
[Parameter(ParameterSetName='Default')]
[Parameter(ParameterSetName='Source')]
[switch]
${AsJob},
[System.Management.AuthenticationLevel]
${Authentication},
# pingMonitor
# http://learn-powershell.net/2013/04/19/sharing-variables-and-live-objects-between-powershell-runspaces/
# http://www.zerrouki.com/powershell-menus-host-ui-promptforchoice-defined-or-dynamic/
$ComputerName = 'HCB-MSYS02'
$code = {
param (
[System.String] $ComputerName,
function New-RunspacePool{
<#
.SYNOPSIS
Create a new runspace pool
.DESCRIPTION
This function creates a new runspace pool. This is needed to be able to run code multi-threaded.
.EXAMPLE
$pool = New-RunspacePool
Description
@gravejester
gravejester / Get-VMWareResourceStatus.ps1
Created October 15, 2014 13:54
Get resource status from VMWare vSphere
function Get-VMWareResourceStatus {
<#
.SYNOPSIS
Get resource status from VMWare vSphere
.DESCRIPTION
Get overall status, configuration status and any configuration issues on VMWare resources by querying vSphere.
.EXAMPLE
Get-VMWareResourceStatus -VIServer 'VIServer01' -ResourceType 'VirtualMachine'
@gravejester
gravejester / Get-VMWareSnapshot.ps1
Created October 17, 2014 11:12
Get-VMWareSnapshot
function Get-VMWareSnapshot {
[CmdletBinding()]
param (
# vSphere server(s) to connect to
[Parameter()]
[string[]] $VIServer,
# Filter snapshots on VM Name
[Parameter()]
[string[]] $VMName
@gravejester
gravejester / New-DataTable.ps1
Created October 20, 2014 11:11
New-DataTable
function New-DataTable {
<#
.SYNOPSIS
Create a new DataTable.
.DESCRIPTION
Create a new DataTable.
.EXAMPLE
`
$myColumns = [ordered] @{
ID = [int32]
@gravejester
gravejester / Compare-DataTable.ps1
Created October 20, 2014 12:43
Compare-DataTable
function Compare-DataTable {
<#
.SYNOPSIS
Compare two DataTables.
.DESCRIPTION
Compare two DataTables.
.EXAMPLE
Compare-DataTable -ReferenceTabel $table1 -DifferenceTable $table2 -CompareMode 'Full'
Performes a full compare of $table1 and $table2
.NOTES