Skip to content

Instantly share code, notes, and snippets.

View aaronpmiller's full-sized avatar

Aaron Miller aaronpmiller

  • Minneapolis, MN
View GitHub Profile
@aaronpmiller
aaronpmiller / New-SMSStatusMsg.ps1
Created March 3, 2015 06:06
Method to raise status messages with SCCM
Function New-SMSConnection {
PARAM(
[Parameter(Mandatory=$true)][string]$siteServer,
[Parameter(Mandatory=$true)][string]$siteCode
)
$smsNamespace = "root\sms\site_$siteCode"
$Locator = New-Object -com "WbemScripting.SWbemLocator"
$Locator.Security_.AuthenticationLevel = 6
$Connection = $Locator.ConnectServer($siteServer, $smsNamespace)
Return $Connection
@aaronpmiller
aaronpmiller / Update-WUMU_ExcludeKBVariables.ps1
Created March 19, 2015 14:55
PowerShell script to create a series of SMS TSEnvironment variables with the prefix WUMU_ExcludeKB to tell ZTIWindowsUpdate to skip these updates
<#
.SYNOPSIS
This script will create a series of SMS TSEnvironment variables with the prefix WUMU_ExcludeKB to tell ZTIWindowsUpdate to skip these updates.
.DESCRIPTION
This is an adaptation of a script provided by "The Deployment Guys" to exclude updates that cause multiple restarts as document in Microsoft KB2894518.
What's (primarily) different in this script:
1) Added logic to fallback to a list of known updates that cause this issue if we can't connect to the Microsoft KB.
@aaronpmiller
aaronpmiller / Get-FileShareReport.ps1
Created March 19, 2015 16:21
PowerShell script to create a CSV file containing a list of ACEs (access control entries) for all file paths at and under the root path specified.
<#
.SYNOPSIS
Create a CSV file containing a list of ACEs (access control entries) for all file paths at and under the root path specified.
.DESCRIPTION
This script will pull a list of all directory at and under the root path specified.
In a parallel process it will pull the ACL for each directory and list out each ACE that is not inherited, the ACEs in the root ACL will be listed as is inherited or not.
This script uses the NTFSSecurity module (http://ntfssecurity.codeplex.com/) to work around long path issues via an embeded AlphaFS .NET class. Please ensure this module in in the PSModulePath. As an added benefity this class appears to be faster at enumerating directories as well.
@aaronpmiller
aaronpmiller / Set-RemotePasswordGUI.ps1
Last active February 22, 2023 15:33
Powershell WPF Form for setting a remote password via netapi32.netuserchangepassword
PARAM (
$domainFQDN = $((Get-WmiObject Win32_ComputerSystem).Domain)
)
#The XAML Form
[string]$formXAML = @"
<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Remote Password Reset" Height="300" Width="500" ResizeMode="NoResize" SizeToContent="WidthAndHeight" MinWidth="500" WindowStartupLocation="CenterScreen">
$counters = (Get-Counter -ListSet Process).Counter | ? {$_ -like "*Bytes"} | % {$_.Replace('*','Powershell*')}
[string[]]$CounterNames = $counters | % {$_.split('\')[-1].ToLower()}
[string[]]$itemProperties = @()
$itemProperties += 'Timestamp'
$itemProperties += $CounterNames | ForEach-Object {$_.Replace('bytes','(MB)')}
$blankItem = '' | Select $itemProperties
Get-Counter -Counter $counters -SampleInterval 2 -Continuous| % {
$item = $blankItem
$item.Timestamp = $_.Timestamp
$groups = $_.countersamples | Group-Object {Split-Path $_.Path -Leaf}
Function Get-CodeplexDownload {
PARAM(
[string]$projectName
)
try {
$releaseURI = "http://$projectName.codeplex.com/releases"
$response = Invoke-WebRequest -Uri $releaseURI
#$version = $response.Links.FindById('fileDownload0').outerText
$version = ($response.AllElements | ? {$_.Class -eq 'page_title wordwrap'} | Select -First 1).outerText.Split(' ') | ? {$_ -like "*[0-9]"}
$changeSetId = $response.Links.FindById('ChangesetIDAnchor').outerText
Function Import-Excel {
<#
.Synopsis
Converts an Excel document into an array of objects with the columns as separate properties.
.Example
Import-Excel -Path .\Example.xlsx
This example would import the data stored in the Example.xlsx spreadsheet.
.Description
The Import-Excel cmdlet converts an Excel document into an array of objects whose property names are determined by the column headers and whose values are determined by the column data.
Additionally, you can specify whether this particular Excel file has any headers at all, in which case the objects will be given the property names based on their column. Likewise, if the document has headers, but one column does not, its data will be assigned a Column# property name.
Function Get-ADNestedMemberOf ($userName) {
# For a specified user get the groups it is a member of recursively.
$targetUser = Get-ADUser $userName
$results = Get-ADGroup -Filter {member -RecursiveMatch $targetUser.DistinguishedName}
return $results
}
Function Test-ADIsMember ($objectDN, $groupDN) {
# params require full DistinguishedName
# Generalized for any ADObject and the return is the not null test. This Will produce the same errors as the standard IsMember if either object doesn't exist
@aaronpmiller
aaronpmiller / userChrome.css
Created May 12, 2016 15:58
Windows 10 color Firefox 38 userChrome active window inactive tab label white
@namespace url(http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul);
.tabbrowser-tab:not([selected=true]) .tab-label { color: white !important; }
.tabbrowser-tab:-moz-window-inactive .tab-label { color: black !important; }