Skip to content

Instantly share code, notes, and snippets.

View turboBasic's full-sized avatar
🔮
Focusing

andriy melnyk turboBasic

🔮
Focusing
View GitHub Profile
@turboBasic
turboBasic / New-PowershellProfiles.ps1
Last active May 30, 2018 10:55
[New-PowershellProfiles.ps1] Create all #powershell profiles #configureWindows
$profile |
Get-Member -memberType NoteProperty |
ForEach-Object {
if (Test-Path $profile.($_.Name)) {
Return
}
$args = @{
path = $profile.($_.Name)
itemType = 'File'
@turboBasic
turboBasic / Autounattend.xml
Created May 29, 2018 15:04
[Autounattend.xml] Good customized settings for the new Windows installation. Tested on Windows 10 Pro for Workstations, release 1803, both as Hyper-V VM and Native boot VHD
<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
<!-- Save this to file Autounattend.xml and put it on root-dir of your device -->
<settings pass="windowsPE">
<component name="Microsoft-Windows-International-Core-WinPE" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SetupUILanguage>
<UILanguage>en-US</UILanguage>
@turboBasic
turboBasic / Suspend-Computer.ps1
Created May 31, 2018 01:10
[Suspend-Computer.ps1] #powershell
$powerState = [System.Windows.Forms.PowerState]::Suspend
$force = $false
$disableWake = $false
[System.Windows.Forms.Application]::SetSuspendState(
$powerState, $force, $disableWake
)
@turboBasic
turboBasic / writelog.ps1
Created July 1, 2018 01:28
[writelog.ps1] Register event source, create event log, write messages to event log #powershell #.Net
# create Event log
using namespace System.Diagnostics
$log = New-Object -TypeName EventLog
$log.Source = 'PillowBook'
$template = $log.Source + ': {0,10}: Execute script: {1}'
if ( -not $log::SourceExists($log.Source) )
{
@turboBasic
turboBasic / psscripts.ini
Created July 1, 2018 02:17
C:\Windows\System32\GroupPolicy\User\Scripts\psscripts.ini: file for running Powershell scripts from Group policy
[ScriptsConfig]
StartExecutePSFirst=true
EndExecutePSFirst=true
[Logon]
0CmdLine=writelog1.ps1
0Parameters=
[Logoff]
0CmdLine=writelog2.ps1
0Parameters=
@turboBasic
turboBasic / penrose-triangle.png
Last active July 14, 2018 08:03
penrose-triangle
penrose-triangle.png
@turboBasic
turboBasic / Resize-Image.ps1
Last active July 15, 2018 16:11 — forked from someshinyobject/PowerShell: Resize-Image
[Resize-Image.ps1] Installation: `Install-Package -ProviderName Gist -Name Resize-Image.ps1 -Source turboBasic; Import-Module $ENV:localAppData/Oneget/Gist/Resize-Image.ps1'
<#
.SYNOPSIS
Resize an image
.DESCRIPTION
Resize an image based on a new given height or width or a single dimension and a maintain ratio flag.
The execution of this CmdLet creates a new file named "OriginalName_resized" and maintains the original
file extension
.PARAMETER Width
The new width of the image. Can be given alone with the MaintainRatio flag
.PARAMETER Height
@turboBasic
turboBasic / Get-DecryptedSecureString.ps1
Created July 21, 2018 20:04
[Get-DecryptedSecureString] :: Decrypts secure strings eg. from [System.Management.Automation.PSCredential], Get-Credential etc.
function Get-DecryptedSecureString( [System.Security.SecureString] $secureString )
{
return [System.Runtime.InteropServices.Marshal]::PtrToStringUni(
[System.Runtime.InteropServices.Marshal]::SecureStringToCoTaskMemUnicode(
$secureString
))
}
@turboBasic
turboBasic / Send-EnvironmentChangeEvent.ps1
Last active July 21, 2018 22:34
[Send-EnvironmentChangeEvent] :: Broadcasts message to all Windows processes about changes in the Environment variables
function Send-EnvironmentChangeEvent {
DATA ImportWin32Declaration {'
[DllImport("user32.dll", EntryPoint = "SendMessageTimeout")]
public static extern IntPtr SendMessageTimeout(
IntPtr hWnd, UInt Msg, UIntPtr wParam, String lParam, UInt fuFlags, UInt uTimeout, out UIntPtr lpdwResult
);
'}
if (-not ("Win32.NativeMethods" -as [Type])) {
@turboBasic
turboBasic / WindowsIdeas.md
Last active July 23, 2018 06:52
Windows Infrastructure ideas (yet to be converted to ToDos)