Skip to content

Instantly share code, notes, and snippets.

@megamorf
megamorf / Powershell Printer monitoring - Get-WInEvent with FilterHashtable
Last active August 29, 2015 14:18
Powershell Printer monitoring - redundant AD query
# in reference to: https://iamsquib.wordpress.com/2015/03/27/print-monitoring-with-powershell/
# bad
Get-WinEvent -Logname='Microsoft-Windows-PrintService/Operational' -Computername printserver | where{$_.userid -eq 307 } | select TimeCreated, ID, UserId, Message
# returns all contents of the Operational log from the remote server and filters them locally
# better
Get-WinEvent -FilterHashtable @{logname='Microsoft-Windows-PrintService/Operational'; id=307} -Computername printserver | select TimeCreated, ID, UserId, Message
# returns filtered results from remote server, no further filtering needed
@megamorf
megamorf / Install-LinuxToolChain
Last active October 15, 2019 07:21
Powershell function to help setting up the Linux toolchain for UE4
function Install-LinuxToolChain {
<#
.SYNOPSIS
Downloads and installs the UE4 linux toolchain components.
.DESCRIPTION
Downloads the clang compiler to $ToolChainDestination and creates a
system-wide environment variable pointing to it.
Afterwards you have to regenerate the UE4 engine project files and
@megamorf
megamorf / MPEnablePlus.reg
Created November 26, 2015 19:37
Windows 10 Malware Schutz aktivieren
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender\MpEngine]
"MpEnablePus"=dword:00000001
; http://www.heise.de/newsticker/meldung/Windows-mit-verstecktem-Adware-Killer-3023579.html
function Get-UACStatus {
<#
.SYNOPSIS
Gets the current status of User Account Control (UAC) on a computer.
.DESCRIPTION
Gets the current status of User Account Control (UAC) on a computer. $true indicates UAC is enabled, $false that it is disabled.
.NOTES
Version : 1.0
@megamorf
megamorf / Call-Example.ps1
Last active January 1, 2016 10:07
Printer Wake Up Script
# with different set of printer shares
.\WakeUpPrinters.ps1 -PrinterShareNames @('printer4_ShareName','printer5_ShareName','printer6_ShareName')
# with additional verbose output
.\WakeUpPrinters.ps1 -Verbose
@megamorf
megamorf / FirewallStatus.Tests.ps1
Created February 14, 2016 13:05
Pester - Firewall test
param($ComputerName = $env:computername)
Describe 'Firewall is enabled' {
BeforeAll {
$session = New-PSSession -ComputerName $ComputerName
$Param = @{Session=$session}
}
$testCases = @(
@{
@megamorf
megamorf / ConfigurationData.psd1
Created April 12, 2016 07:26
DSC - ConfigurationNames with ConfigurationData
@{
AllNodes = @(
@{
NodeName = 'Node1'
Role = 'ExampleRole1'
},
@{
NodeName = 'Node2'
Role = 'ExampleRole2'
},
@megamorf
megamorf / Get-TelekomDataStatus.ps1
Created September 21, 2016 09:37
Query Telekom Mobile Data Status
Function Get-TelekomDataStatus
{
$IsConnected = Get-NetAdapter -Physical | where{$_.status -eq 'up' -and $_.MediaType -eq 'Wireless WAN'}
if($IsConnected)
{
Invoke-RestMethod -Uri 'http://pass.telekom.de/api/service/generic/v1/status'
}
else
{
Write-Warning "Nicht mit WWAN verbunden - Abfrage nicht möglich"
@megamorf
megamorf / TrustAllCertsPolicy.ps1
Created September 23, 2016 16:44
PowerShell - Ignore SSL errors
add-type @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertsPolicy : ICertificatePolicy {
public bool CheckValidationResult(ServicePoint srvPoint, X509Certificate certificate,
WebRequest request, int certificateProblem) {
return true;
}
}
"@
@megamorf
megamorf / Access API with OAuth 2.0 Access Token.ps1
Created September 23, 2016 16:46
Webrequest - Authorization
$headers = @{}
$headers.Add('Authorization', "Bearer $accesstoken")
Invoke-RestMethod -Headers $headers -Uri https://graph.microsoft.com/v1.0/me -Method Get