Skip to content

Instantly share code, notes, and snippets.

View KurtDeGreeff's full-sized avatar

Kurt De Greeff KurtDeGreeff

View GitHub Profile
#Requires -Version 5.0.9814.0
if(!($PSVersionTable.PSVersion.Major -ge 5 -and $PSVersionTable.PSVersion.Build -ge 9814)) {
"Sorry you need PSVersion 5.0.9814.0 or newer"
$psversiontable
return
}
Add-Type -AssemblyName presentationframework
function New-Log {
<#
.SYNOPSIS
Create a new log.
.DESCRIPTION
The New-Log function is used to create a new log file or Windows Event log. A log object is also created
and either saved in the global PSLOG variable (default) or sent to the pipeline. The latter is useful if
you need to write to different log files in the same script/function.
.EXAMPLE
New-Log '.\myScript.log'
#Requires -RunAsAdministrator
#Requires -Version 3.0
#References:
#Getting Started with Nano Server <https://technet.microsoft.com/en-us/library/mt126167.aspx>
#Quick Guide - Deploying Nano Server using PowerShell <http://deploymentresearch.com/Research/Post/479/Quick-Guide-Deploying-Nano-Server-using-PowerShell>
param (
#[ValidateScript({ Test-Path $_ })]
$ConvertWindowsImageScriptPath = 'D:\work\NanoServerSetup\Convert-WindowsImage.ps1'
@KurtDeGreeff
KurtDeGreeff / ToastNotification_Windows10.ps1
Last active September 16, 2015 10:31 — forked from altrive/ToastNotification_Windows10.ps1
Windows 10 toast notification sample
$ErrorActionPreference = "Stop"
$notificationTitle = "Notification: " + [DateTime]::Now.ToShortTimeString()
[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] > $null
$template = [Windows.UI.Notifications.ToastNotificationManager]::GetTemplateContent([Windows.UI.Notifications.ToastTemplateType]::ToastText01)
#Convert to .NET type for XML manipuration
$toastXml = [xml] $template.GetXml()
$toastXml.GetElementsByTagName("text").AppendChild($toastXml.CreateTextNode($notificationTitle)) > $null
@KurtDeGreeff
KurtDeGreeff / RemoteFileTransferTest.ps1
Last active September 16, 2015 10:40 — forked from altrive/RemoteFileTransferTest.ps1
PowerShell v5 Remote File Transfer feature usage
#Requires -RunAsAdministrator
#Requires -Version 5.0
$ErrorActionPreference = "Stop"
function Main
{
#Size of dummy file, that transffered by PSRemoting.
$fileSize = 10MB
@KurtDeGreeff
KurtDeGreeff / EventTracingManagement.ps1
Last active September 16, 2015 10:43 — forked from altrive/EventTracingManagement.ps1
EventTracingManagement Cmdlets Test (added in Windows 10)
$ErrorActionPreference = "Stop"
Import-Module EventTracingManagement #Require Windows 10 enviroment(it use underlying CIM APIs https://msdn.microsoft.com/en-us/library/dn919685%28v=vs.85%29.aspx)
Use-NuGetPackage Microsoft.Diagnostics.Tracing.TraceEvent -Verbose #Require PSNuGet<https://github.com/altrive/PSNuGet>
$sessionName = "MyRealTimeSession"
$providerName = "Sample.EtwTrace"
$providerGuid = [Microsoft.Diagnostics.Tracing.Session.TraceEventProviders]::GetEventSourceGuidFromName($providerName)
try
{
# Our XAML for the WPF-based GUI.
$inputXAML = @"
<Window x:Name="Pick_Console" x:Class="LetUsWPF.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:LetUsWPF"
mc:Ignorable="d"
Title="MainWindow" Height="275" Width="410">
function Show-Map {
<#
.Synopsis
Launches a map in the browser using an address from the command line or the clipboard
#>
param(
$address,
[Switch]$UseBing
)
@KurtDeGreeff
KurtDeGreeff / Get-WindowsLogonEvents.ps1
Created October 6, 2015 11:53 — forked from sunnyc7/Get-WindowsLogonEvents.ps1
Script to parse Windows login data from Forwarded Events.
$eventLogCollector= 'MYSERVER'
#XML Filter for Get-WinEvent
$eventFilter = @"
<QueryList>
<Query Id="0" Path="ForwardedEvents">
<Select Path="ForwardedEvents">*[System[(EventID=4624 or EventID=4800 or EventID=4801 or EventID=4634)]]</Select>
</Query>
</QueryList>
"@
function Get-ComputerWMIInfo {
<#
.Synopsis
Retrieves WMIObjects for a computer.
.DESCRIPTION
Retrieves WMIObjects for a computer and formats the information for readability.
.INPUTS
String
A string is recieved by the ComputerName and WMIObject parameter.
.OUTPUTS