Skip to content

Instantly share code, notes, and snippets.

@manualbashing
manualbashing / credential.ps1
Created January 21, 2020 12:21
[Create Credential Object] #powershell
$secpasswd = ConvertTo-SecureString "PlainTextPassword" -AsPlainText -Force
New-Object System.Management.Automation.PSCredential ("username", $secpasswd)
@manualbashing
manualbashing / yes_no.ps1
Created January 21, 2020 11:35
[Yes / No User choice] #powershell
$options = [System.Management.Automation.Host.ChoiceDescription[]] @("&Yes", "&No")
[int]$defaultchoice = 1
$option = $host.UI.PromptForChoice($Title, $Info, $Options, $defaultchoice)
switch($option)
{
0 { Write-Host "Yes – Write your code"}
1 { Write-Host "No – Write your code"}
}
@manualbashing
manualbashing / mount_iso.ps1
Created January 16, 2020 11:00
[Mount ISO File to VM] #PowerCLI
Get-CDDrive -VM $sql01 | Set-CDDrive -IsoPath "[SQL] SQL2017_DE.iso" -Confirm:0
Get-CDDrive -VM $sql01 | Set-CDDrive -Connected $true -Confirm:0
@manualbashing
manualbashing / copy_datastore.ps1
Created January 16, 2020 10:51
[Copy File to Datastore] #PowerCLI
$ds = Get-Datastore -Name SQL
Copy-DatastoreItem -Item C:\Administration\SQL2017_DE.iso -Destination $ds.DatastoreBrowserPath
@manualbashing
manualbashing / New-IsoFile.ps1
Last active January 16, 2020 10:49
[Create ISO file] #powershell
function New-IsoFile
{
<#
.Synopsis
Creates a new .iso file .Description The New-IsoFile cmdlet creates a new .iso file containing content from chosen folders
.Example
New-IsoFile "c:\tools","c:Downloads\utils"
This command creates a .iso file in $env:temp folder (default location) that contains c:\tools and c:\downloads\utils folders. The folders themselves are included at the root of the .iso image.
.Example
New-IsoFile -FromClipboard -Verbose
@manualbashing
manualbashing / psshutdown.md
Last active January 7, 2020 14:37
[psshutdown Cheatsheet] #sysinternals
@manualbashing
manualbashing / azure-custom-script-extension-run-as-user.ps1
Created January 6, 2020 22:31 — forked from gregjhogan/azure-custom-script-extension-run-as-user.ps1
How to run a script as a different user in an Azure VM Custom Script Extension
Enable-PSRemoting -Force
$credential = New-Object System.Management.Automation.PSCredential @(($AdminDomain + "\" + $AdminUsername), (ConvertTo-SecureString -String $AdminPassword -AsPlainText -Force))
Invoke-Command -FilePath $PSScriptRoot\setup-as-user.ps1 -Credential $credential -ComputerName localhost
@manualbashing
manualbashing / arm_cheatsheet.md
Last active January 2, 2020 22:27
[Azure Resource Manager Cheatsheet]

Custom Script Extension

Download Path for Script Files

C:\Packages\Plugins\Microsoft.Compute.CustomScriptExtension\1.10.3\Downloads\0

Log File Path

@manualbashing
manualbashing / azure_functions_cheat.md
Created December 30, 2019 14:05
[Azure Functions Cheatsheet]

Exclude files from deployment

A project folder may contain language-specific files and directories that shouldn't be published. Excluded items are listed in a .funcignore file in the root project folder.

@manualbashing
manualbashing / background_image.json
Created December 27, 2019 12:30
Set a background image to #vscode
"background.useDefault": false,
"background.customImages": [
"https://raw.githubusercontent.com/rwu823/vscode-bg-img/master/images/17/baby-black.png",
"https://raw.githubusercontent.com/rwu823/vscode-bg-img/master/images/17/baby-white.png",
"/your/patch/image"
],
"background.style": {
"background-position": "95% 95%",
"background-size": "20%",
"opacity": 0.8