Skip to content

Instantly share code, notes, and snippets.

@MyITGuy
MyITGuy / base_silent.cmd
Last active August 29, 2015 13:56
JRE installation wrapper that verifies Java is not in-use at the time of installation
@ECHO OFF
SET JRE_RUNNING=
SET PROBLEM=
SET INST_FILE=%~n1
SET LOG_DIR=%windir%\system32\LogFiles
SET CMD_OPTS= /s REBOOT=ReallySuppress /L*v "%LOG_DIR%\%INST_FILE%_inst.log"
ECHO.
ECHO Check for installer requirements...
ECHO.
@MyITGuy
MyITGuy / AeX_License_Counts.sql
Last active August 29, 2015 13:56
SQL/SMP: Display License Counts
SELECT
[conn2].[Name]
, [conn1].[TotalCount]
, [conn1].[LicenseInUseCount]
, [PercentageUsed] = (
CASE
WHEN [conn1].[LicenseInUseCount] > 0 THEN ROUND(((CAST ([conn1].[LicenseInUseCount] AS FLOAT) / 100.0) / (CAST( [conn1].[TotalCount] AS FLOAT ) / 100.0)) * 100, 2)
ELSE 0
END
)
@MyITGuy
MyITGuy / ruleset_example.xml
Last active August 29, 2015 13:56
Example ruleset.xml
<!-- Example Deployment Rule Set that allow a desktop administrator to control end-user's execution of browser applets.
See http://docs.oracle.com/javase/7/docs/technotes/guides/jweb/security/deployment_rules.html -->
<ruleset version="1.0+">
<rule>
<id location="http://payroll.example.org" />
<action permission="run" />
</rule>
<rule>
<id location="http://knownvendor.example.com/program" />
<!-- For example if an application is known not to work on Java 1.7 -->
@MyITGuy
MyITGuy / AeX_ComputersWithSCOM.sql
Created March 5, 2014 20:15
SQL/SMP: Computers with System Center Operations Manager
-- Computers with System Center Operations Manager
SELECT [Name] = UPPER([Name])
FROM [vComputer]
WHERE [Guid] IN (
SELECT [_ResourceGuid]
FROM [Inv_AeX_AC_NT_Services]
WHERE [Name] = 'HealthService'
)
ORDER BY [Name]
@MyITGuy
MyITGuy / smpAutomationEmailCheck.ps1
Last active August 29, 2015 13:57
PowerShell: sendMail Function
[CmdletBinding(SupportsShouldProcess=$True)]
param (
#SMTP server name
[string]$smtpServer = "smtp",
[string]$From,
#[string]$ReplyTo = "",
[string]$To,
[string]$Cc,
[string]$Subject = "Automation Policies Email Verification",
[switch]$Export
@MyITGuy
MyITGuy / javacpl.ps1
Created March 22, 2014 14:36
Java Control Panel Applet Utility
<#
.SYNOPSIS
Add and remove Java Control Panel applet entries in the Windows Control Panel.
.DESCRIPTION
The JavaCPL function collects control panel applet information from the registry. It uses this information to analyze currently visible entries and their status. Based on this information entries can be removed, added or modified.
.PARAMETER Add
Add available Java Control Panel applets to the Windows Control Panel. Existing Java Control Panel applets will not be affected.
.PARAMETER Remove
Remove Java Control Panel applets that are not installed from the Windows Control Panel. Available Java Control Panel applets will remain.
.PARAMETER All
@MyITGuy
MyITGuy / InvSoln.cmd
Created March 24, 2014 20:32
Allows the running of InvSoln.exe without knowning the installation location.
@ECHO OFF
:: Get the Install Path from the registry
FOR /F "tokens=3*" %%A IN ('REG.EXE QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Altiris\Altiris Agent\Plugin Objects\Agents\InvAgent" /V "Install Path" ^| FINDSTR /i /c:"Install Path"') DO SET InstallPath=%%B
IF NOT DEFINED InstallDir (
FOR /F "tokens=3*" %%A IN ('REG.EXE QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432NODE\Altiris\Altiris Agent\Plugin Objects\Agents\InvAgent" /V "Install Path" ^| FINDSTR /i /c:"Install Path"') DO SET InstallPath=%%B
)
IF NOT DEFINED InstallDir GOTO:EOF
IF DEFINED InstallDir ECHO InstallPath: %InstallPath%
@MyITGuy
MyITGuy / DeleteMyBakProfile.ps1
Created March 24, 2014 20:40
Corrects an issue whereas a user is constantly logged in with a TEMP profile when a profile directory is no longer on the file system. This is due to the profile still existing in the registry.
Get-ItemProperty -Path "Registry::HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\$((New-Object System.Security.Principal.NTAccount($env:USERNAME)).Translate([System.Security.Principal.SecurityIdentifier]).Value).bak" -Name "ProfileImagePath" | Select -ExpandProperty ProfileImagePath | % {$ProfileImagePath = "$($_)" ; Write-Host "ProfileImagePath: $($ProfileImagePath) - " -NoNewline ; if ((Test-Path $ProfileImagePath) -eq $true) {Write-Host "Profile image path found." -ForegroundColor Green} else {Write-Host "Profile image path does not exist." -ForegroundColor Red ; Remove-Item -Path "Registry::HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\$((New-Object System.Security.Principal.NTAccount($env:USERNAME)).Translate([System.Security.Principal.SecurityIdentifier]).Value).bak" -Confirm}}
@MyITGuy
MyITGuy / get_content_string_crlf_fix.ps1
Created March 28, 2014 21:42
Corrects carriage returns when Get-Content is used. Works for SQL files so commented lines are respected.
[string]::Join("`r`n",(Get-Content -Path "File.sql") -replace ([regex]::Escape("{00000000-0000-0000-0000-000000000000}"), $Some.Name))
@MyITGuy
MyITGuy / list_db_users.sql
Last active August 29, 2015 14:00
List the users communicating with a given database.
DECLARE @T TABLE
(
-- sp_who2 utilizes sys.sysprocesses (loosely)
--http://technet.microsoft.com/en-us/library/ms179881.aspx
[spid] SMALLINT,
[status] VARCHAR(50),
[login] VARCHAR(50),
[hostname] VARCHAR(50),
[blk] VARCHAR(50),
[dbname] VARCHAR(50),