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
<# | |
.Synopsis | |
Glossary Module | |
.DESCRIPTION | |
A Powershell Module that includes a function for searching a CSV file which is a Glossary of terms and presents the results in a variety of formats. | |
.EXAMPLE | |
Search-Glossary MyTerm | |
.EXAMPLE | |
Search-Glossary MyTerm -PassThru | Export-CSV MyTerms.csv | |
#> |
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
#Adapted from here http://mikefrobbins.com/2012/08/30/finding-aliases-for-powershell-cmdlet-parameters/ | |
(get-command *).parameters.values | select name,aliases | sort aliases -unique | sort name | |
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 stats on length of the cmdlet name such as max, min, average, sum | |
Get-Command | where CommandType -eq cmdlet | select -ExpandProperty name | measure length -Average -Sum -Max -Min | |
# See the list, sorted by length | |
Get-Command | where CommandType -eq cmdlet | select -ExpandProperty name | sort length | |
#Another way to get this statistic using calculated properties | |
Get-Command | where CommandType -eq cmdlet | select name,@{N='length';E={$_.name.length}} | measure length -Average -Sum -Max -Min | |
# See the list this way, sorted by length (we can skip the select and use the expression in sort) |
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-XKCD{ | |
[cmdletbinding(DefaultParameterSetName=’Specific’)] | |
Param ( | |
[Parameter(ParameterSetName=’Specific’,ValueFromPipeline=$True,Position=0)][int[]]$Num, | |
[Parameter(ParameterSetName=’Random’)][switch]$Random, | |
[Parameter(ParameterSetName=’Random’)][int]$Min = 1, | |
[Parameter(ParameterSetName=’Random’)] | |
[int]$Max = ((Invoke-WebRequest "http://xkcd.com/info.0.json").Content | ConvertFrom-Json).num, | |
[Parameter(ParameterSetName=’Newest’)][int]$Newest, | |
[switch]$Download |
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
# Required module - BuildHelpers: https://github.com/RamblingCookieMonster/BuildHelpers | |
[cmdletbinding()] | |
Param( | |
[string]$PSGalleryKey = (Import-Clixml PSGalleryKey.xml), #So I don't put it on the internet. | |
[string]$Module, | |
[string]$Version, | |
[switch]$Publish | |
) | |
$ModuleData = (Get-Module $Module) |
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-WmiObject Win32_logicaldisk | Export-Clixml "$env:computername-LogicalDisks.xml" | |
(Get-Service | select name,displayname,status) | Export-Clixml "$env:computername-Services.xml" | |
(Get-WmiObject Win32_NetworkAdapterConfiguration | Where-Object {$_.IPEnabled -eq "True"}) | Export-Clixml "$env:computername-Network.xml" |
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-PartOfDay { | |
Param ( | |
[int]$Hour = (Get-Date).Hour | |
) | |
Switch ($Hour) { | |
{$_ -in 0..11} {'Morning'} | |
{$_ -in 12..17} {'Afternoon'} | |
{$_ -in 18..23} {'Evening'} | |
} | |
} |
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
Install-Module <modulename> -scope CurrentUser |
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-ClassDefinitionFromObject { | |
[CmdletBinding()] | |
param( | |
[Parameter(Mandatory)] | |
[object]$InputObject, | |
[Parameter()] | |
[String]$Name = 'Root', | |
[SupportsWildcards()] |
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 Convert-DateProperties { | |
<# | |
.SYNOPSIS | |
Converts string properties that have 'date' in their name to datetime properties, recursively in all levels of an object. | |
.PARAMETER object | |
The object to convert. | |
.PARAMETER name | |
The string that should be matched in the name property of the object. Default = 'Date'. | |
.EXAMPLE | |
$MyObj | Convert-DateProperties |