Skip to content

Instantly share code, notes, and snippets.

@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 / Deployment.Properties.txt
Created March 18, 2014 20:31
Example deployment.properties file
#deployment.properties
# Security Tab
# Enable Java content in the browser
deployment.webjava.enabled=true
deployment.webjava.enabled.locked
# Security Level
deployment.security.level=MEDIUM
deployment.security.level.locked
@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 / WhatIsMySID.ps1
Last active March 3, 2022 21:01
PowerShell: What is my SID?
(New-Object System.Security.Principal.NTAccount($env:USERNAME)).Translate([System.Security.Principal.SecurityIdentifier]).Value
@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 / Win32_QuickFixEngineering.ps1
Last active November 1, 2023 19:01
List installed hotfixes.
Get-CimInstance -ClassName Win32_QuickFixEngineering | Where-Object { $_.InstalledOn -ge "1/26/2014 12:00:00 AM"} | Select InstalledOn,HotFixID | fl *
@MyITGuy
MyITGuy / LogParser.cmd
Last active June 9, 2021 04:23
LogParser Examples
logparser "SELECT * FROM 'D:\LogFiles\W3SVC1\u_ex140121.log' WHERE [cs-uri-stem] LIKE '%PostEvent.aspx'" -o:DataGrid
@MyITGuy
MyITGuy / administrator_context.ps1
Last active April 8, 2024 18:28
Check if user has Administrator role
function Test-AdministratorContext {
[CmdletBinding()]param()
$CurrentWindowsIdentity = [System.Security.Principal.WindowsIdentity]::GetCurrent()
$CurrentWindowsPrincipal = New-Object System.Security.Principal.WindowsPrincipal($CurrentWindowsIdentity)
$IsAdministratorContext = $CurrentWindowsPrincipal.IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator)
Write-Verbose "Current Context Is Administrator = $IsAdministratorContext"
return $IsAdministratorContext
}