Skip to content

Instantly share code, notes, and snippets.

@mbrownnycnyc
mbrownnycnyc / exit-appassuremaintenance.ps1
Last active August 29, 2015 14:05
Take a Dell AppAssure core server out of "maintenance mode"
#https://support.software.dell.com/kb/119400
Import-Module AppAssurePowerShellModule
Sc.exe Config AppAssureCore Start= Delayed-Auto
Start-Service AppAssureCore
Resume-Snapshot –All
Resume-Replication -outgoing [hostname of remote core] -all
Resume-Replication -incoming [hostname of remote core] -all
Resume-Vmexport –All
@mbrownnycnyc
mbrownnycnyc / get-adusersid.ps1
Created September 2, 2014 19:45
get a sid for an AD user
function get-adusersid{
#http://community.spiceworks.com/how_to/show/2776-powershell-sid-to-user-and-user-to-sid
param(
[string]$domain,
[string]$user
)
$objUser = New-Object System.Security.Principal.NTAccount("$domain", "$user")
$strSID = $objUser.Translate([System.Security.Principal.SecurityIdentifier])
@mbrownnycnyc
mbrownnycnyc / get-aduserbysid.ps1
Created September 2, 2014 19:45
get an AD user from a sid
function get-aduserbysid{
#http://community.spiceworks.com/how_to/show/2776-powershell-sid-to-user-and-user-to-sid
param(
[string]$domain,
[string]$sid
)
$objSID = New-Object System.Security.Principal.SecurityIdentifier `
@mbrownnycnyc
mbrownnycnyc / charting.psm1
Last active August 29, 2015 14:06
charting "made easy" module: http://goodworkaround.com/node/64
# Load assembly for Microsoft Chart Controls for Microsoft .NET Framework 3.5
Write-Verbose "Loading assemblies"
[void][Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
[void][Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms.DataVisualization")
<#
.Synopsis
Creates a new chart
.DESCRIPTION
New-Chart creates a new chart object with an optional default dataset. This object is a System.Windows.Forms.DataVisualization.Charting.ChartArea and can be used with either the other methods in this module, or manually.
@mbrownnycnyc
mbrownnycnyc / make-achart.ps1
Created September 11, 2014 00:44
charting "made easy" module example: http://goodworkaround.com/node/64
Import-Module .\charting.psm1 -Force
# Create simple dataset
$simpleDataset = @{
"Microsoft" = 800
"Apple" = 250
"Google" = 400
"RIM" = 0
}
@mbrownnycnyc
mbrownnycnyc / check-filepresence.ps1
Last active August 29, 2015 14:06
A quick script to email a report about file presence.
#this script is to check for the presence of files
#this will populate a variable with the specified format of today's date (see format specifier http://msdn.microsoft.com/en-us/library/8kb3ddd4%28v=vs.110%29.aspx)
$yyyy = $(Get-Date -format yyyy) # "2014"
$mmmm = $(Get-Date -format MMMM) # "September"
$mm = $(Get-Date -format MM) # "09"
$dd = $(Get-Date -format dd) # "22"
#if today is Friday
@mbrownnycnyc
mbrownnycnyc / get-outlookprofileserver.ps1
Last active August 29, 2015 14:07
script that returns info about a user's outlook profile, specifically if they are configured to use a CAS hub or a hostname... error handling and logging are super cheaply done (I'm not proud of it)
function get-adusersid{
#http://community.spiceworks.com/how_to/show/2776-powershell-sid-to-user-and-user-to-sid
param(
[string]$domain,
[string]$user
)
$objUser = New-Object System.Security.Principal.NTAccount("$domain", "$user")
$strSID = $objUser.Translate([System.Security.Principal.SecurityIdentifier])
$strSID.Value
@mbrownnycnyc
mbrownnycnyc / set-dnsservers.ps1
Last active August 29, 2015 14:07
script to set DNS servers of all IP enabled NICs on a host
#http://blogs.technet.com/b/heyscriptingguy/archive/2012/02/28/use-powershell-to-configure-static-ip-and-dns-settings.aspx
function set-dnsservers {
param(
[string[]]$dnsservers,
[string]$computername
)
#you must filter by ip address, otherwise it will affect all ipenabled NICs, which will include any iSCSI
$wmi = get-wmiobject -ComputerName $computername win32_networkadapterconfiguration -filter "ipenabled='true'" | where {$_.ipaddress -like "192.168.50*" }
@mbrownnycnyc
mbrownnycnyc / send-events.ps1
Last active August 29, 2015 14:07
This is a local (or remote) querier of machines to check for critical and error events in the system event log. If found, it will send errors in a decently/readably formatted email to a given address.
$computer = $env:COMPUTERNAME
$checkintervalmins = 60
$checkintervalms = (new-timespan -minutes $checkintervalmins).totalmilliseconds
#http://www.mcbsys.com/techblog/2011/04/powershell-get-winevent-vs-get-eventlog/
@mbrownnycnyc
mbrownnycnyc / notify-userpasswordexpiring.ps1
Created October 20, 2014 18:58
password expiration notification, modified
#################################################################################################################
#
# Version 1.1 May 2014
# Robert Pearman (WSSMB MVP)
# TitleRequired.com
# Script to Automated Email Reminders when Users Passwords due to Expire.
#
# modified by matt brown
#
# Requires: Windows PowerShell Module for Active Directory