Skip to content

Instantly share code, notes, and snippets.

View Chirishman's full-sized avatar
⚔️
I guess statuses are a thing now

Chirishman

⚔️
I guess statuses are a thing now
View GitHub Profile
function ConvertTo-OrderedDictionary
{
#requires -Version 2.0
[CmdletBinding()]
param (
[Parameter(Mandatory = $true, ValueFromPipeline = $true)]
[hashtable]
$InputObject,
@Chirishman
Chirishman / ConvertTo-PSON.ps1
Last active July 23, 2018 16:56
Convert to PowerShell Object Notation
function ConvertTo-PSON {
<#
.SYNOPSIS
Generates a PowerShell object-notation in the style of a PSD1 document
.DESCRIPTION
This stringifies a PowerShell object following the style of a PSD1 document, the powerShell-equivalent of JSON. The behavior is incomplete but works fine for simple objects.
.EXAMPLE
$array=@()
$array+=Get-Process wi* | Select-Object Handles,NPM,PM,WS,VM,CPU,Id,ProcessName
ConvertTo-PSON $array
@Chirishman
Chirishman / Show-CommandGUI.ps1
Created December 13, 2017 18:53
Improved Show-Command
function Show-CommandGUI($command){
$hlpIcon='AAABAAQAAAAAAAEAIADd9wAARgAAADAwAAABACAAqCUAACP4AAAgIAAAAQAgAKgQAADLHQEAEBAAAAEAIABoBAAAcy4BAIlQTkcNChoKAAAADUlIRFIAAAEAAAABAAgGAAAAXHKoZgAAIABJREFUeJzsvXecXdddL/pdu5w6c870XtRGlmx1y7JsSZblKhcgtoNDkkc8GhECjyTweHk8eBcCF8IH7qNcIPddPsB7PB7EiWMnJiYKsePkYrnJVYqtPiojjTSj6WdOL7us98feq+1zRpZ707JHZ5fV1+/3/ZVVNnA5XA6Xw+VwOVwOl8PHL5D3uwKXw5sLu4eGEgDaALQCaKaUNgNoBJD0/+oB1BFCogCiAMIAQgAMAJqfjQvABlABUAZQpJQWAeQAZCmlGULIPIAUgDnXdecATNm2PfWNBx9Mv0dNvRzeg3AZAD6AYffQEAHQD6CPUtoLoAdANyGks76+vretrZ22trbqiWRDuK6uLhKLxqOGqYcN3Qzpuh4CIQZ1qQ5QQiklrksJpRSEAC4FAApN0wAKClBKNI2CUsel1HZdp+LYTqVSLpeLpWIpl8+X0vOpyszMjDU7O6Nls5lzAC5QSscAnKeUnnccZ/Tw4cNn9h84QAHQ963jLoc3HS4DwAcg7B4aWgJgGaV0GSFkMYCl/f2LOvv6+s22tra6RCKZiEQidYZhRDSNmLpuIBQKwTAMmKYOwzBgGAY0TYeuazAMHZqmQdM0EKJB0wgIUYfadV1QSuG4LlzHheM4cBwHtu3AcWxUKhYsy4ZtWyiXKyiXK7BtB5S6luM4xXK5nMtk09mZ6en82Nh569y50QuU0tMATlNKT7mue/Kf/+VfTvnFXQaFD2i4DADvQ9g9NHQlgBWU0isBXLF02cCypYuXRNs7O5N1dfUN4VC4LhwyjVA4hHA4hFAoBNM0EQ6FoGkaKpaFSqUCy2aMasG2LFQsG7Zlw7
Configuration UpdateAndScheduleReboot{
Param(
[string]$NodeName='localhost',
[datetime]$TargetRebootTime
)
Import-DscResource –ModuleName ’PSDesiredStateConfiguration’
Import-DSCResource -ModuleName xPendingReboot
Import-DSCResource -ModuleName xWindowsUpdate
@Chirishman
Chirishman / RalyksReport.htm
Last active December 19, 2017 14:24
Example rewrite of Ralyks' Report
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Testing</Title>
<style type="text/css">
* {
margin: 0;
}
html {
@Chirishman
Chirishman / Get-ADGroupMembership.ps1
Last active December 21, 2017 04:43
Test dashboard - Auth with LM or AD
function Get-ADGroupMembership {
Param(
[Parameter(
Position = 0,
Mandatory = $true,
ValueFromPipelineByPropertyName = $true
)]
[Alias('UserName','UN')]
[String]
$User
#Lookup Notmatch
$Event = @{
[int64]12 = "Boot"
13 = "Shutdown"
}
@($event[[int64]12],$event[12],$event[13],$event[[int64]13]) | % { Write-Output "Result: $_" }
#Can and Can't Be Defined
Import-Module Get-ChildItemColor
if ( -not $env:ConEmuPID ) {
function global:prompt {
-join($(
if (test-isadmin) {"λ "}),"$($env:username.ToUpper()) ►► ")
}
}
else {
$ColorSuffix = 'm'
@Chirishman
Chirishman / CohenFTP.ps1
Last active January 15, 2018 18:22
Cohen's request for PowerShell help
#Option A
#run this only the first time
Get-PSCredential | Export-Clixml -Path $env:USERPROFILE\TheseCreds.xml
Get-PSCredential | Export-Clixml -Path $env:USERPROFILE\FTPCreds.xml
#leave this in
$cred = Import-Clixml -Path $env:USERPROFILE\TheseCreds.xml
$FTPCreds = Import-Clixml -Path $env:USERPROFILE\FTPCreds.xml