Skip to content

Instantly share code, notes, and snippets.

View Nora-Ballard's full-sized avatar

Nora Ballard Nora-Ballard

View GitHub Profile
REM ElevationCheck
whoami /groups | find "S-1-16-12288" > nul
if "%errorlevel%"=="0" (
echo Running as elevated user. Continuing script.
) else (
echo Not running as elevated user.
Pause
goto :EOF
)
##Requires -Version 2.0
function New-TrayNotifyIcon
{
param(
[parameter(Mandatory=$false, ValueFromPipelineByPropertyName=$true)]
[Alias('Icon')]
$IconPath = "$env:windir\system32\WindowsPowerShell\v1.0\powershell.exe",
[parameter(Mandatory=$True, ValueFromPipelineByPropertyName=$true)]
$Title,
function Get-PrinterDriverFiles($ComputerName = '.')
{
$Win32_PrinterDriver = get-wmiobject -class 'Win32_PrinterDriver' -namespace 'root\CIMV2' -ComputerName $ComputerName
ForEach ($Printer in $Win32_PrinterDriver) {
$Printer.DependentFiles | ForEach-Object {
[pscustomobject] @{
"Printer" = $Printer.Name
"FullName" = $_
"Name" = Split-Path -Path $_ -Leaf
param(
$ComputerList = ("$env:COMPUTERNAME"),
$Cred = $(Get-Credential "$env:USERDOMAIN\$env:USERNAME")
)
$Result1 = Invoke-Command -ComputerName $ComputerList -Credential $Cred -ScriptBlock {
$Win32_OperatingSystem = Get-WmiObject -Class 'Win32_OperatingSystem'
$LastBootUpTime = $Win32_OperatingSystem.ConvertToDateTime($Win32_OperatingSystem.LastBootUpTime)
function Get-TSMClientEvents
{
Param(
[Parameter(Mandatory=$true, ValueFromPipeline=$True, ValueFromPipelineByPropertyName=$true)]
$ComputerName
)
PROCESS
{
if ($ComputerName -is [Array])
{
function Get-TSMClientSchedule
{
Param(
[Parameter(Mandatory=$true, ValueFromPipeline=$True, ValueFromPipelineByPropertyName=$true)]
$ComputerName
)
PROCESS
{
if ($ComputerName -is [Array])
{
@Nora-Ballard
Nora-Ballard / MoveRDPtoConsole.bat
Created February 15, 2014 14:14
Moves the active RDP session of the specified user to the physical console, the session remains unlocked. This allows one to leave the physical console unlocked after using RDP. Great for Media Center PC or Nvidia/Steam Game Streaming. See https://serverfault.com/questions/428975/how-to-use-tscon-on-windows7
@ECHO OFF
if "%1" == "" goto error
for /f "skip=1 tokens=3 usebackq" %%s in (
`query user %1%`
) do (
echo Setting %%s to console.
%windir%\System32\tscon.exe %%s /dest:console
)
:: Get Blade Position from WMI, requires HP providers installed.
For /F "delims== tokens=1-2" %%c in ('wmic /namespace:\\root\HPQ Path HP_BladeCSLocation Get PhysicalPosition /format:value^|find "PhysicalPosition=" ') do set PhysicalPosition=%%d
:: C7000 chassis has 16 slots, make sure it is not out of range.
if NOT %PhysicalPosition% gtr 0 IF NOT %PhysicalPosition% lss 17 GOTO Invalid_Bay_Number
:: Pad to 2 digits.
if %PhysicalPosition% lss 10 set PhysicalPosition=0%PhysicalPosition%
@Nora-Ballard
Nora-Ballard / Enable_iSCSI_MPIO.bat
Created February 15, 2014 18:54
Claim all Windows iSCSI disks for MPIO
:MPIO
echo MPIO: Checking claimed BusTypes.
SET MSFT_BUSTYPE_iSCSI=MSFT2005iSCSIBusType_0x9
FOR /f "tokens=* delims==" %%G IN ('mpclaim -h ^|find "%MSFT_BUSTYPE_iSCSI%"') DO SET FOUND_iSCSI=%%G
mpclaim -h
echo.
if (%FOUND_iSCSI%) == ("%MSFT_BUSTYPE_iSCSI%") GOTO MPIO_Complete
:MPIO_Claim
@Nora-Ballard
Nora-Ballard / InternetTests.ps1
Created February 20, 2014 22:37
Functions for testing internet connectivity. Uses the Microsoft NCSI by default, but anything can be passed by parameter.
function Get-ExternalIP
{
$URL = 'http://ifconfig.me/all.xml'
$ProxyURL = [System.Net.WebRequest]::GetSystemWebProxy().GetProxy($URL).AbsoluteUri
$resp = Invoke-WebRequest -Uri $URL -Method Get -Proxy $ProxyURL -ProxyUseDefaultCredentials
$([xml]$resp).info.ip_addr
}
function Test-InternetConnection