Skip to content

Instantly share code, notes, and snippets.

@mattmcnabb
mattmcnabb / DoughutChart.ps1
Last active December 2, 2017 02:23
Create a disk space doughnut chart
$disks = Get-WmiObject -ClassName Win32_LogicalDisk
ForEach ($disk in $disks) {
$FreeSpace = [Math]::Round($disk.FreeSpace / 1GB, 2)
$UsedSpace = [Math]::Round(($Disk.Size - $disk.FreeSpace) / 1GB, 2)
New-UDColumn -Content {
New-UdChart -Title $Disk.DeviceId -Type Doughnut -Endpoint {
[PSCustomObject]@{Space = $UsedSpace; Name = "UsedSpace"},
[PSCustomObject]@{Space = $FreeSpace; Name = "FreeSpace"} |
Out-UDChartData -DataProperty "Space" -LabelProperty "Name"
}
@mattmcnabb
mattmcnabb / cloudSettings
Created August 24, 2017 03:00
Visual Studio Code Settings Sync Gist
{"lastUpload":"2017-08-24T02:59:49.349Z","extensionVersion":"v2.8.3"}
@mattmcnabb
mattmcnabb / Test-DynamicParameter.ps1
Last active March 6, 2017 00:50
Dynamic Parameter Tab Completion Bug?
function Test-DynamicParameter
{
[CmdletBinding()]
PARAM
(
[string[]]
$Param1,
# this parameter seems to cause the problem - if I specify [string] then tab-completion works for -DynamicParameter
[PSCredential]
@mattmcnabb
mattmcnabb / Test-ADStaffAttributes.ps1
Last active February 11, 2018 06:58
Line-Of-BusinessTesting
function Test-ADStaffAttributes {
[CmdletBinding()]
param
(
[Parameter(Mandatory = $true)]
[Microsoft.ActiveDirectory.Management.ADUser]
$Identity,
[switch]
$Quiet
@mattmcnabb
mattmcnabb / AsyncMailbox.ps1
Created January 8, 2017 22:04
Testing Async calls to Office 365
$PowerShell = [powershell]::Create()
$null = $PowerShell.AddScript({
param($Credential)
$ExchParams = @{
ConfigurationName = 'microsoft.exchange'
ConnectionUri = "https://outlook.office365.com/powershell-liveid/"
Credential = $Credential
Authentication = 'Basic'
@mattmcnabb
mattmcnabb / MyCompleter.ps1
Created January 6, 2017 16:04
Tab completion with argument completers
# set up a test command
function Test-MyCompleter {
param
(
[string[]]
$Param1
)
}
# register the completer
@mattmcnabb
mattmcnabb / PresPolicies.ps1
Created December 19, 2016 16:51
Office 365: Auto-Create Onedrive Preservation Policies
param
(
[PSCredential]
$Credential,
[string]
$TenantName,
[int]
$PreservationDurationInDays,
@mattmcnabb
mattmcnabb / 1.ps1
Last active November 12, 2016 14:28
OMS-custom-monitor_1
Import-Module OneLogin
$Credential = Get-Credential
$Token = New-OneLoginToken -Credential $Credential -Region us -SetAsDefault
$Events = Get-OneLoginEvent -Since (Get-Date).AddHours(-1)
@mattmcnabb
mattmcnabb / PasswordExpiration.ps1
Created October 28, 2016 01:00
Password Expiration Notice and Report
<#
.DESCRIPTION
Finds all users in Active Directory with passwords close to expiring
and notifies them via email. Also creates and sends a report that includes all
expired and expiring passwords.
#>
#Requires -Version 3.0
#Requires -Module ActiveDirectory
param
@mattmcnabb
mattmcnabb / PoshRS.ps1
Created September 30, 2016 02:45
Trouble with array in PoshRSJob
# set up a simple array
$Items = @(
[PSCustomObject]@{Name = 'Item1'; SomeProperty = "1"},
[PSCustomObject]@{Name = 'Item2'; SomeProperty = "2"},
[PSCustomObject]@{Name = 'Item3'; SomeProperty = "3"}
)
### enumerate a property of the objects passed in via -ArgumentList
# the output here is always '2'