Skip to content

Instantly share code, notes, and snippets.

View gravcat's full-sized avatar

poppoppop gravcat

View GitHub Profile
@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 / 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 / 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 / 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
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#requires –runasadministrator
try
{
& choco -h
}
catch
{
# If chocolatey help wasn't available, invoke expression to install from Chocolatey.org
iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
}
# must be run in administrator context
param (
[String] $path, # file or folder
[String] $perm, # fullcontrol, read, write, etc
[String] $action = "allow" #allow or deny
[String] $user
)
$arguments = $user, $perm, $action
# to be run in any normal user-spawned powershell prompt
Start-Process powershell -Verb runas -argumentlist "& lxrun /install /y"
@gravcat
gravcat / bootstrap-w10-orch.ps1
Last active September 25, 2017 05:23
get chocolatey pkg mgr to install openssh, then configure locally for sshd usage
<# -----------------------------------------------------------------------------
bootstrap_w10_orch.ps1
.Description
Get a Windows 10 box into a state where SSH is ready and available.
Also try to get Windows Subsystem for Linux (WSL) prepped and ready.
When run via CSE, this script is downloaded into:
C:\Packages\...
@gravcat
gravcat / check-linuxos.psm1
Created June 2, 2017 16:39
a powershell function to check whether or not you are running in a linux (or linux-like) environment. powershell on linux is a thing now
<# -----------------------------------------------------------------------------
Check-LinuxOS()
.Description
Check whether or not a host you are running from is Linux. WMI is not yet
available in the PowerShell alpha.
----------------------------------------------------------------------------- #>
function Check-LinuxOS {
$ErrorActionPreference = "SilentlyContinue" # Prevents stop when Windows explodes with uname call