Skip to content

Instantly share code, notes, and snippets.

View gravcat's full-sized avatar

poppoppop gravcat

View GitHub Profile
@gravcat
gravcat / cse-test-file-write.ps1
Last active August 29, 2017 13:33
using CustomScriptExtension, hopefully writes a file out on the local fs
Write-Output "Hello!" | Out-File C:\Users\nucleus\Desktop\hello.txt
@gravcat
gravcat / lxss-via-tasksched.ps1
Last active February 2, 2018 15:53
workaround to install and initiate the Windows Subsystem for Linux via Task Scheduler
if (!(Test-Path "C:\_maintainer")) {
New-Item -Type Directory "C:\_maintainer"
}
Invoke-WebRequest -Uri "https://gist.githubusercontent.com/gravcat/4ceb977916c5f551cae44375296ab72a/raw/c514ad8212460396813d88c6ffbdb0954c233eb5/modify-local-activation-dcom.ps1" `
-OutFile "C:\_maintainer\modify-local-activation-dcom.ps1"
Add-Content -Value "lxrun /install /y" -Path "C:\_maintainer\lxrun_install.bat"
Add-Content -Value "copy /y nul C:\_maintainer\lxrun_install_complete" -Path "C:\_maintainer\lxrun_install.bat"
@gravcat
gravcat / InstallWU.ps1
Created September 1, 2017 05:35
an interesting windows update script i found on a w10 box i rented through azure
# Ensure that current process can run scripts.
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process -Force
$ErrorActionPreference = "Stop"
$ConfirmPreference = "none"
Start-Transcript $env:TEMP\patchlog.log -Force
try
{
Install-Module -Name PSWindowsUpdate -Force -Verbose
Write-Host "Installation Started"
Get-WUInstall -AcceptAll -AutoReboot -Verbose
@gravcat
gravcat / modify-local-activation-dcom.ps1
Created September 7, 2017 21:44
How to append/manipulate DCOM permission configuration via (elevated) PowerShell
<#############
This was really difficult to figure out,
but here's a snippet that will allow you to modify DCOM ACLs.
Easily modified to touch other properties in DCOM ACL-land.
#############>
# get the Object based on the AppId. This example AppID belongs to the Linux Subsystem DCOM object
$wmi = (Get-WmiObject -Class Win32_DCOMApplicationSetting -Filter "AppId='{e82567ae-2ea4-4dbc-bc68-8b0a0526d8d5}'" -EnableAllPrivileges)
# get the Launch Descriptor object and store
@gravcat
gravcat / vm_create_adhoc_machine_cse.ps1
Last active March 19, 2018 18:50
enables you to quickly create a single azure vm with all the basic required supporting infrastructure
<# -----------------------------------------------------------------------------
vm_create_and_run_cse.ps1
.Description
Create an adhoc VM completely standalone, and run CSE if you'd like.
Get you some OSes! : https://docs.microsoft.com/en-us/azure/virtual-machines/windows/cli-ps-findimage
Publishers
- MicrosoftWindowsServer
@gravcat
gravcat / run-cse.ps1
Last active September 29, 2017 17:47
quickly run cse on an azure vm with a given script, vm name, and resource group name
$ErrorActionPreference = 'SilentlyContinue'
$rg = "gravcat195"
$location = "westus"
$fileName = "install-wsl-nopasswd.ps1"
$fileUri = "https://gist.githubusercontent.com/gravcat/397b330d4154a55f76e03de5b8f7ca18/raw/be0dde4e715cef0a6aa0719f0a29242c3c954402/$fileName"
$cseId = "cse"
Set-AzureRmVMCustomScriptExtension -ResourceGroupName $rg -VMName "$rg-vm" -location 'westus' -FileUri $fileUri -run $fileName -name $cseId -Argument "-username nucleus -password W3ARhkLrdQK8"
Start-Sleep -Seconds 3
@gravcat
gravcat / random-dcom-acl.ps1
Created September 11, 2017 05:38
i found this somewhere
function New-DComAccessControlEntry {
param(
[Parameter(Mandatory=$true, Position=0)]
[string]
$Domain,
[Parameter(Mandatory=$true, Position=1)]
[string]
$Name,
@gravcat
gravcat / install-sshd.ps1
Last active September 11, 2017 21:58
install-sshd.ps1 from OpenSSH-Win32 0.0.20.0
# @manojampalam - authored initial script
# @friism - Fixed issue with invalid SDDL on Set-Acl
# @manojampalam - removed ntrights.exe dependency
# @bingbing8 - removed secedit.exe dependency
$scriptpath = $MyInvocation.MyCommand.Path
$scriptdir = Split-Path $scriptpath
$sshdpath = Join-Path $scriptdir "sshd.exe"
$sshagentpath = Join-Path $scriptdir "ssh-agent.exe"
param (
[String]
$SSHPort = "22",
[String]
$version = "v0.0.20.0",
[String]
$packageName = "OpenSSH-Win64",
param (
[String]
$SSHPort = "22",
[String]
$version = "v0.0.20.0",
[String]
$packageName = "OpenSSH-Win64",