Skip to content

Instantly share code, notes, and snippets.

View Graham-Beer's full-sized avatar

Graham Beer Graham-Beer

View GitHub Profile
@Graham-Beer
Graham-Beer / Format-Member.ps1
Last active September 4, 2018 13:10
Alternative to Get-Member with a cleaner output to host
function Format-Member {
[CmdletBinding()]
[alias("fm")]
param (
[parameter(ValueFromPipeline, ValueFromPipelineByPropertyName)]
[System.Management.Automation.PSObject]
$InputObject
)
@Graham-Beer
Graham-Beer / Find-PipelineParameters.ps1
Created July 12, 2018 18:32
Discover pipeline parameters on cmdlets
filter Find-PipelineParameters {
param (
[Parameter(ValueFromPipeline, ValueFromPipelineByPropertyName)]
[System.Management.Automation.CommandInfo] $CommandInfo
)
$commandInfo.Parameters.Values | Where-Object {
$parameterAttribute = $_.Attributes |
Where-Object { $_ -is [Parameter] }
$parameterAttribute.ValueFromPipeline -or $parameterAttribute.ValueFromPipelineByPropertyName
}
@Graham-Beer
Graham-Beer / Invoke-FileSystemWatcher.ps1
Created June 20, 2018 07:56
Creation of File System Watcher class and subscribed events.
enum EventName {
Created
Changed
Deleted
Renamed
}
function Invoke-FileSystemWatcher {
[CmdletBinding()]
param (
class AwsInstance {
[String] $TagName
[String] $InstanceId
[String] $Status
Hidden [Object] $EC2Instance
AwsInstance([String]$name) {
if ($name -match '^i-[a-f0-9]+$') {
$this.InstanceId = $name
@Graham-Beer
Graham-Beer / Get-DinoPW.ps1
Created April 23, 2018 15:12
Little function to make use of 'Dinopass' api
filter Get-DinoPW {
param (
[Parameter(ValueFromPipeline, ValueFromPipelineByPropertyName)]
[ValidateSet('Simple', 'Strong')]
$SetPwStrength
)
$uri = switch ($SetPwStrength) {
'Simple' { 'http://www.dinopass.com/password/simple' }
'Strong' { 'http://www.dinopass.com/password/strong' }
}
function Get-NameInBinary {
param(
[parameter(DontShow)] # hide paramter to allow read host to promt for name(s)
[string]$name = $(read-host -Prompt "Enter Name(s)")
)
# Pass name from function to screen
"Your Name '{0}' in Binary is : " -f $name
# get the value of whitespace in binary to seperate names, surnames or middle names
function Get-age {
param(
[Parameter(Mandatory=$true,
HelpMessage="Date must be written as dd/mm/yy",
Position=0)]
[ValidatePattern("^(0[1-9]|[12]\d|3[01])/(0[1-9]|1[0-2])/(\d{2})$")]
[string]$Bday
)
Begin {
.Synopsis
Get deployment status of application
.DESCRIPTION
By querying the SCCM WMI class of "SMS_AppDeploymentAssetDetails", can obtain the status of a deployment.
Adding the application name and the collection of which the application was targeted, status results can be obtained.
A filter is set for the 5 status results which the MSDN documentation stats are avaiable.
.LINK
Please see 'https://msdn.microsoft.com/en-us/library/hh948459.aspx' for the class details of "SMS_AppDeploymentAssetDetails"
.EXAMPLES
5 examples available:
Synopsis
Find where an application has been deployed to.
.DESCRIPTION
To determine which collection an application has been deployed to. Results will show Name of application, the deployment ID
and the collection the application has been deployed to.
.EXAMPLE
get-AppDeployedToCollection -Application 'Microsoft Office 2016'
.OUTPUTS
Application_Name DeploymentID Deployed_To_Collection
---------------- ------------ ----------------------
Synopsis
Find where an application has been deployed to.
.DESCRIPTION
To determine which collection an application has been deployed to. Results will show Name of application, the deployment ID
and the collection the application has been deployed to.
.EXAMPLE
get-AppDeployedToCollection -Application 'Microsoft Office 2016'
.OUTPUTS
Application_Name DeploymentID Deployed_To_Collection
---------------- ------------ ----------------------