Skip to content

Instantly share code, notes, and snippets.

@amit-g
amit-g / DriveReorganization
Created September 1, 2023 01:36
Apps Script - DriveReorganization
function enumerateFolders(folders) {
while (folders.hasNext()) {
let folder = folders.next();
console.log(folder.getName());
}
}
function enumerateFoldersInRootFolder() {
let folders = DriveApp.getRootFolder().getFolders();
console.log("Folders in root folder");
& 'C:\Program Files\OpenSSL\bin\openssl.exe' req -x509 -nodes -keyout C:\Certs\self-signed-key.pem -out C:\Certs\self-signed-cert.pem -subj '/CN=localhost'
# New-Item -ItemType SymbolicLink -Path "key.pem" -Target "C:\Certs\self-signed-key.pem"
# New-Item -ItemType SymbolicLink -Path "cert.pem" -Target "C:\Certs\self-signed-cert.pem"
npx http-server --ssl --cert C:\Certs\self-signed-cert.pem --key C:\Certs\self-signed-key.pem
@amit-g
amit-g / GithubGitTips.md
Last active February 23, 2023 19:09
Github Git Tips

Configure username and email

git config --global user.name "Amit G"
git config --global user.email "amit-g@users.noreply.github.com"

Set default branch to something other than master

git config --global init.defaultBranch main
@amit-g
amit-g / Microsoft.PowerShell_profile.ps1
Created February 21, 2023 08:34
Microsoft.PowerShell_profile.ps1
Import-Module -Name Terminal-Icons
oh-my-posh --init --shell pwsh --config https://gist.githubusercontent.com/amit-g/898df4ae41af11b58b00d00978769e26/raw/be8e68a58df2c80cfd396587fe42d9f6abace297/omp.json | Invoke-Expression
Function Set-LocationDocuments { Set-Location "${env:USERPROFILE}/Documents" }
Function Set-LocationDownloads { Set-Location "${env:USERPROFILE}/Downloads" }
Function Get-GitConfigNames { git config --global user.name; git config --global user.email; git config user.name; git config user.email; }
Set-Alias cddoc Set-LocationDocuments
@amit-g
amit-g / Automation Account Hybrid Worker Cleanup.md
Created February 1, 2023 17:29
Automation Account Hybrid Worker Cleanup

Run uninstall twice (it might fail first time)

  • C:\Packages\Plugins\Microsoft.Azure.Automation.HybridWorker.HybridWorkerForWindows\0.1.0.12\bin\uninstall.ps1

Further cleanup

  • Delete Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Azure\HybridWorker
  • Delete Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\HybridRunbookWorkerV2
  • Uninstall service - sc.exe delete HybridWorkerService
  • Delete C:\Packages\Plugins\Microsoft.Azure.Automation.HybridWorker.HybridWorkerForWindows\1.1.5
@amit-g
amit-g / Set-MyAzKeyVaultSecret.ps1
Created January 20, 2023 02:39
Data entry function for creating key vault secret
$KeyValultName = "YourKeyVaultName"
function Set-MyAzKeyVaultSecret($SecretName)
{
$SecretValue = Read-Host -Prompt "Please enter the secret value for $SecretName" -AsSecureString
Set-AzKeyVaultSecret -VaultName $KeyValultName -Name $SecretName -SecretValue $SecretValue
}
@amit-g
amit-g / OutlookJunkEmailData.ps1
Last active February 20, 2023 18:34
Outlook Junk Email Data
Connect-MgGraph -UseDeviceAuthentication -ContextScope Process -Scopes "Mail.Read", "Mail.ReadWrite", "Mail.ReadBasic"
Get-MgUser
$UserId = (Get-MgUser).Id
Get-MgUserMailFolder -UserId $userId -Filter "startswith(displayName, 'Junk')" | Format-List
$MailFolderId = (Get-MgUserMailFolder -UserId $userId -Filter "startswith(displayName, 'Junk')" | Select-Object -First 1).Id
Get-MgUserMailFolderMessage -UserId $userId -MailFolderId $MailFolderId -Property "sender, subject" -Top 1000 | Select-Object @{ n='EmailDomain'; e={$_.Sender.EmailAddress.Address -Replace '[^@]+@', ''} }, @{ n='EmailAddress'; e={$_.Sender.EmailAddress.Address;} }, @{ n='Name'; e={$_.Sender.EmailAddress.Name} }, @{ n='Subject'; e={$_.Subject;} } | ConvertTo-Csv -NoTypeInformation > OutlookJunk-$(Get-Date -Format 'yyyyMMdd').csv
@amit-g
amit-g / omp.json
Created December 17, 2022 00:02
Oh my posh settings
{
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"blocks": [
{
"alignment": "left",
"segments": [
{
"background": "#c386f1",
"foreground": "#ffffff",
"leading_diamond": "\ue0b6",