Skip to content

Instantly share code, notes, and snippets.

View VertigoRay's full-sized avatar
🔌
😏

Raymond Piller VertigoRay

🔌
😏
View GitHub Profile
@VertigoRay
VertigoRay / SCCM2012-DeleteInvalideDrivers.ps1
Last active December 14, 2015 09:50
SCCM 2012 - Driver Importing. This code to deletes drivers with bad sources.
$a = (Get-WmiObject -ComputerName 'myserver.fqdn' -Namespace 'root\SMS\Site_XXX' -Class 'SMS_Driver' | ?{!(test-path $_.ContentSourcePath)})
$a | %{$_.delete()}
@VertigoRay
VertigoRay / ServiceRecovery.cmd
Last active December 14, 2015 12:29
Used with Win Service Recovery to recover servers that Exit Unclean. Will log to file and retry n times. Implementation Screenshots: http://imgur.com/a/dmqq8
@echo off
setlocal
SET /A RETRYMAX=10
SET LOG=%SystemRoot%\Logs\ServiceRecovery.log
FOR /F "tokens=2*" %%a in ('sc query %1 ^| findstr STATE') do SET STATUS=%%b
SET STATUS=%STATUS: =%
IF ERRORLEVEL 1 goto _errawr
IF "%STATUS%"=="4RUNNING" goto:eof
@VertigoRay
VertigoRay / Uninstaller.vbs
Last active December 14, 2015 13:09
This will Query WMI for the specified program and uninstall it with Windows Installer - which covers about 90% of our supported applications. All actions are logged to %SystemRoot%\Logs\SCCM.
Option Explicit
' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' Usage:
' cscript.exe Uninstaller.vbs ApplicationName [LogFileName]
'
' Parameters:
' ApplicationName The Product Name of the Program you want to Uninstall. This will
' remove all instances of the program, so be as specific as you want.
' - Example: "Adobe" would remove all Adobe products (anything with Adobe in the Name)
' - Example: "Adobe Reader" will remove all versions of Adobe Reader.
@VertigoRay
VertigoRay / ProductsInstalled.vbs
Created March 5, 2013 16:49
This will Query WMI for all of the Programs installed with Windows Installer - which covers about 90% of our supported applications. Results are written to ProductsInstalled.txt in the Working Dir.
Option Explicit
' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' Usage:
' cscript.exe ProductsInstalled.vbs
'
' Description:
' This will Query WMI for all of the Programs installed with Windows Installer - which covers about 90%
' of our supported applications. Results are written to ProductsInstalled.txt in the Working Dir.
'
' Output Format:
@VertigoRay
VertigoRay / Install.vbs
Last active February 23, 2017 06:00
This is a simple Install Wrapper. I use it with SCCM 2012 to allow STDOUT to be captured and sent to a log file, since STDOUT appears to be lost when deploying software as an SCCM 2012 Application.
Option Explicit
' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' FIRST THINGS FIRST:
' Change this DeploymentTypeName to match the Deployment Type Name used in the Application.
' - It's just used to for the log file name.
' - For Uninstall action, append ".x" to name, such as: Application - Install.x
' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dim DeploymentTypeName
DeploymentTypeName = "CAS Remote - Install"
' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@VertigoRay
VertigoRay / init.pp
Created July 17, 2013 20:39
Puppet - sethostname /etc/puppet/modules/common/sethostname/manifests/init.pp
class sethostname {
file { "/etc/hostname":
ensure => present,
owner => root,
group => root,
mode => 644,
content => "$::fqdn\n",
notify => Exec["set-hostname"],
}
exec { "set-hostname":
@VertigoRay
VertigoRay / InstallFirefox.ps1
Last active June 8, 2016 15:31
You'll want to sign the code so you can run it without changing the execution policy to unrestricted. Sample Usage: InstallFirefox.ps1 22.0 http://go.vertigion.com/PowerShell-InstallFirefox
Param (
[parameter(
Position = 0,
Mandatory = $true,
HelpMessage = 'This is the version number, such as "22.0". Valid version numbers can be found here: http://mzl.la/1c9hPmo'
)]
[string] $version,
[parameter(
Position = 1,
Mandatory = $false,
@VertigoRay
VertigoRay / gist:6091753
Last active December 20, 2015 07:09
If you're possibly working with unclean data (or typo the DC structure) while checking if OU exists, you'll need to catch your errors.
[string] $Path = 'OU=foo,OU=test,DC=domain,DC=com'
try {
$ou_exists = [adsi]::Exists("LDAP://$Path")
} catch {
# If invalid format, error is thrown.
Throw("Supplied Path is invalid.`n$_")
}
if (-not $ou_exists) {
Throw('Supplied Path does not exist.')
@VertigoRay
VertigoRay / gist:6091801
Last active December 20, 2015 07:09
In my case, I only work within a particular OU in our Domain, so I’ve made it so my $Path can be abbreviated. Forked (https://gist.github.com/VertigoRay/6091753) ... here’s how I handle things:
[string] $RootOU = 'OU=test,DC=domain,DC=com'
[string] $Path = 'OU=foo'
try {
$ou_exists = [adsi]::Exists("LDAP://$Path")
} catch {
# If invalid format, error is thrown.
Write-Debug "Supplied Path is invalid.`n$_"
# It's probably the abbreviated version, so let's tack on the Root OU and confirm exists.
Write-Debug 'Placing Path in Root OU and re-verifying ...'
$Path = "$Path,$RootOU"
@VertigoRay
VertigoRay / is_test_computer.sls
Created August 23, 2013 00:40
List of test computers
{% for computer in 'TEST001','TEST002','TEST003' %}
{% if grains['nodename'] == computer %}
is_test_computer: True
{% else %}
is_test_computer: False
{% endif %}
{% else %}
is_test_computer: False
{% endfor %}