Skip to content

Instantly share code, notes, and snippets.

@gpuido
gpuido / Get-Date_Format_Milliseconds.ps1
Created September 11, 2017 14:22 — forked from lazywinadmin/Get-Date_Format_Milliseconds.ps1
Get-Date -Format with the milliseconds
get-date -for "yyyy-MM-dd HH:mm:ss.fffffff"
2015-05-30 17:07:25.2352256
@gpuido
gpuido / Win32FileVersionInfoBuildPostprocessor.cs
Created September 11, 2017 13:24 — forked from t-mat/Win32FileVersionInfoBuildPostprocessor.cs
[Unity] Editor Extension - Show Win32 Executable FileVersionInfo
using System;
using System.Collections.Generic;
using System.Reflection;
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
using UnityEditor.Callbacks;
#endif
@gpuido
gpuido / desktopsmallicon.cmd
Created September 11, 2017 13:23 — forked from t-mat/desktopsmallicon.cmd
[Win32] [Powershell] Set Desktop Small Icon
@powershell -NoProfile -ExecutionPolicy Unrestricted "%~dp0\desktopsmallicon.ps1" %*
@gpuido
gpuido / ToastNotification_Windows10.ps1
Created September 11, 2017 13:06 — 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
@gpuido
gpuido / PowerShellv5_UsingNamespace.ps1
Created September 11, 2017 13:05 — forked from altrive/PowerShellv5_UsingNamespace.ps1
PowerShell v5 'using namespace' syntax test
#Require -Version 5.0
# using statement must appear before any other statements in a script.
# other using types(Assembly/Command/Module/Type) is not supported yet?
# [Enum]::GetNames('System.Management.Automation.Language.UsingStatementKind')
using namespace System.Diagnostics
using namespace System.Linq
function Main
{
$ErrorActionPreference = "Stop"
#Need to install Nuget packages before execute
Add-Type -Path (Join-Path (Split-Path $profile -Parent) "packages\Windows7APICodePack-Core.1.1.0.0\lib\Microsoft.WindowsAPICodePack.dll" -Resolve)
Add-Type -Path (Join-Path (Split-Path $profile -Parent) "\packages\Windows7APICodePack-Shell.1.1.0.0\lib\Microsoft.WindowsAPICodePack.Shell.dll" -Resolve)
<#
#TODO: Define Interop code to register shortcut with appid
$referencedAssemblies = @(
[MS.WindowsAPICodePack.Internal.PropVariant].Assembly.FullName,
@gpuido
gpuido / PowerShellWebServer.ps1
Created August 25, 2017 11:06 — forked from fearthecowboy/PowerShellWebServer.ps1
PowerShell Webserver that restarts when you edit the script.
#
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@gpuido
gpuido / example.msbuild.xml
Created August 25, 2017 11:05 — forked from fearthecowboy/example.msbuild.xml
Super Simple PowerShell task for MSBuild.
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- @FearTheCowboy's Simple PowerShell Task for MSBuild -->
<UsingTask TaskName="PowerShell" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v12.0.dll">
<ParameterGroup><ScriptBlock ParameterType="System.String" Required="true" /></ParameterGroup>
<Task><Reference Include="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v12.0.dll"/><Code Type="Class" Language="cs"><![CDATA[
public class PowerShell : Microsoft.Build.Tasks.Exec {
public string ScriptBlock {set { EchoOff=true; Command = string.Format( "@powershell \"Invoke-Command -ScriptBlock {{ $errorActionPreference='Stop'; {0} ; exit $LASTEXITCODE }} \"", value.Replace("\"","\"\"").Replace("\r\n",";").Replace("\n",";").Replace("\r",";")); } }
}]]></Code></Task>
</UsingTask>
@gpuido
gpuido / associate-powershell.ps1
Created August 25, 2017 11:04 — forked from fearthecowboy/associate-powershell.ps1
Make PowerShell scripts runnable from anywhere ( ie, CMD.EXE, Explorer, Run Dialog, etc)
#==============================================================================
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@gpuido
gpuido / Install-Stack.ps1
Created August 25, 2017 10:43 — forked from fearthecowboy/Install-Stack.ps1
Install software stack.
###
### Save this file as "install-software.ps1"
###
# check for elevated powershell
write-host -nonewline -fore cyan "Info: Verifying user is elevated:"
If (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
write-host -fore Red "NO"
return write-error "You must run this script elevated."
}