Skip to content

Instantly share code, notes, and snippets.

View 1RedOne's full-sized avatar

Stephen Owen 1RedOne

View GitHub Profile
@1RedOne
1RedOne / Dashboard.ps1
Created October 26, 2017 20:17
FilesOverTime
if ($i -eq $null){$i = 8080}
$i++
$Colors = @{
BackgroundColor = "#FF252525"
FontColor = "#FFFFFFFF"
}
$NavBarLinks = @((New-UDLink -Text "<i class='material-icons' style='display:inline;padding-right:5px'>favorite_border</i> PowerShell Pro Tools" -Url "https://poshtools.com/buy-powershell-pro-tools/"),
(New-UDLink -Text "<i class='material-icons' style='display:inline;padding-right:5px'>description</i> Documentation" -Url "https://adamdriscoll.gitbooks.io/powershell-tools-documentation/content/powershell-pro-tools-documentation/universal-dashboard.html"))
@1RedOne
1RedOne / Write-SCCMLog.ps1
Created October 9, 2017 17:05
SCCM Compliant Log files
function Write-Log {
param(
[Parameter(position=0)][int]$ErrorLevel = 1, # 1 - info, 2 - warning, 3 - error
[Parameter(position=1)][string]$Component ='AWEnroll', # source of the entry
[Parameter(position=2)][string]$Msg,
[Parameter(position=3)][string]$LogFile = "c:\utils\AW\Enroll.log"
)
$TZBias = (Get-WmiObject Win32_TimeZone).bias
$Time = "$(Get-Date -Format 'HH:mm:ss.fff')$TZBias"
@1RedOne
1RedOne / LazyModule.psm1
Created September 18, 2017 18:11
LazyModule.psm1
# Use your module PSM1 to import functions, then run one or two if needed
# Based on Warren Frame's Plaster module format
#
#Get public and private function definition files.
$PublicFunction = @( Get-ChildItem -Path $PSScriptRoot\Public\*.ps1 -Exclude *tests* -ErrorAction SilentlyContinue )
$PrivateFunction = @( Get-ChildItem -Path $PSScriptRoot\Private\*.ps1 -Exclude *tests* -ErrorAction SilentlyContinue )
#Dot source the files
Foreach($import in @($PublicFunction + $PrivateFunction))
@1RedOne
1RedOne / InstallPowerShell.sh
Created August 16, 2017 15:43
InstallPowerShell.sh
# Register the Microsoft RedHat repository
curl https://packages.microsoft.com/config/rhel/7/prod.repo | sudo tee /etc/yum.repos.d/microsoft.repo
# Install PowerShell
sudo yum install -y powershell
# Start PowerShell
powershell
@1RedOne
1RedOne / Progam_v1.cs
Last active July 18, 2017 02:32
GetStats.Exe
using System;
using System.IO;
using System.Net;
using System.Text;
using System.Web;
namespace Examples.System.Ham
{
public class WebRequestGetExample
@1RedOne
1RedOne / AWTypes.ps1xml
Created May 19, 2017 18:54
AirWatch Custom Type
<?xml version="1.0" encoding="utf-8" ?>
<Types>
<Type>
<Name>AirWatch.Automation.Object.Device</Name>
<Members>
<ScriptProperty>
<Name>AcLineStatus</Name>
<GetScriptBlock>
$this.AcLineStatus
</GetScriptBlock>
@1RedOne
1RedOne / ConvertCsv-ToXml.ps1
Created April 25, 2017 14:16
ConvertCsv-ToXml
#Given an input CSV file like the following
Profile,Hostname,IPAddress,OperatingSystem
FoxDeploy-Manual_Patch,MEMWINREP002,192.168.16.64,Server2012
FoxDeploy-Manual_Patch,NASXCH1,192.168.17.10,Server2012
FoxDeploy-Manual_Patch,NASXCH3,192.168.16.112,Server2012
FoxDeploy-Manual_Patch,NASXCH2,192.168.16.55,Server2012
FoxDeploy-SQL,NASSQL03,192.168.16.110,Server2012
#define an XML file
[xml]$xml = "
$keys = $PSCmdlet.MyInvocation.BoundParameters.Keys
foreach ($key in $keys)
{
$keyValue = @{
$true = ",$key"
$false = "?patchFields=$key"
}
$queryParams += $keyValue.($PSCmdlet.MyInvocation.BoundParameters.ContainsKey($key))
}
@1RedOne
1RedOne / PrettyGoodExplanation.ps1
Created January 24, 2017 15:58
Explanation of multiple object output in PowerShell functions
PowerShell ALWAYS does its best to try to make sure it converts output into the most useful format. One of the ways it does this is by seeing the type of object that it is first displaying in a function, and ensuring that all future objects also match this format. Sometimes it's possible, and sometimes it's not.
In the case of your code, PowerShell executes and then tries to emit the results of `Compare-Object`, and succeeds. 'Compare-Object' emits an object that has these properties.
Name MemberType Definition
---- ---------- ----------
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
ToString Method str
@1RedOne
1RedOne / Readme.md
Created December 6, 2016 17:57
PrettyReadmeTemplat
Warning A mild note of caution: The core features of ZeroDSC are implemented and working. Please experiment with ZeroDSC and provide feedback by opening issues and pull requests here. Please also note that it is still early days for this project and many of the features are still experimental and unpolished. Expect breaking changes to ZeroDSC before it stabilizes including changes to the configuration document format, live configuration objects, and the behaviour of the configuration algorithm.

Build status