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
# A one-liner to return the desired output | |
Invoke-RestMethod -Uri 'telize.com/geoip' | Select-Object longitude, latitude, continent_code, timezone | |
# Wrapped with a function - simple but works | |
Function Get-GeoInformation | |
{ | |
[CmdletBinding()] | |
Param | |
( | |
[System.Net.IPAddress] |
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-IPAddress | |
{ | |
[CmdletBinding()] | |
param | |
( | |
[ValidateSet('IPv4','IPv6','All')] | |
[string] | |
$AddressType = 'All', | |
[Parameter(ValueFromPipelineByPropertyName,ValueFromPipeline)] |
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-SvcHost | |
{ | |
<# | |
.SYNOPSIS | |
Returns information about the processes running under each instance of the service host process. | |
.DESCRIPTION | |
Returns information about the processes running under each instance of the service host process of local or remote computers. | |
Uses WMI as the source of this information. | |
.PARAMETER ComputerName | |
Specifies a remote computer to gather information about. Can be a fully-qualified domain name, NetBIOS name, or and IP address. |
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
Describe "Example" { | |
It "Performs short-circuit evaluation" { | |
Test-Path c:\NoDirHere | Should be $true | |
Get-ChildItem c:\NoDirHere -File | Should Not Be $null | |
} | |
} |
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
$list = @" | |
1 Partridge in a pear tree | |
2 Turtle Doves | |
3 French Hens | |
4 Calling Birds | |
5 Golden Rings | |
6 Geese a laying | |
7 Swans a swimming | |
8 Maids a milking | |
9 Ladies dancing |
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
$here = Split-Path -Parent $MyInvocation.MyCommand.Path | |
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace('.Tests.', '.') | |
. "$here\$sut" | |
Remove-EventLog -LogName Pester -ErrorAction SilentlyContinue | |
Describe 'Test-EventLogExists' { | |
Set-StrictMode -Version latest | |
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 New-CustomObject | |
{ | |
param | |
( | |
[Parameter(ValueFromPipeline)] | |
[Object] | |
$InputObject, | |
[Parameter()] | |
[hashtable] |
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-O365UserLicenseReport | |
{ | |
<# | |
.SYNOPSIS | |
Generates a report of Office 365 license assignments | |
.DESCRIPTION | |
Generates a report of Office 365 license assignments by license sku, including individual service plan assignments. | |
This command requires that you have a global administrator account for an Office 365 tenant and can connect to Office 365 using | |
Windows PowerShell. Instructions for this can be found at http://powershell.office.com/. |
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
$ModulePath = Split-Path -Parent $MyInvocation.MyCommand.Path | |
$ModuleName = (Split-Path -Leaf $MyInvocation.MyCommand.Path) -Replace ".Tests.ps1" | |
$ManifestPath = "$ModulePath\$ModuleName.psd1" | |
# test the module manifest - exports the right functions, processes the right formats, and is generally correct | |
Describe "Manifest" { | |
$Manifest = $null | |
It "has a valid manifest" { | |
{ |
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 Test-PSCredential | |
{ | |
param | |
( | |
[PSCredential] | |
$Credential | |
) | |
$Credential | |
} |