Skip to content

Instantly share code, notes, and snippets.

View kkamegawa's full-sized avatar

KAMEGAWA Kazushi kkamegawa

View GitHub Profile
@kkamegawa
kkamegawa / remove-oldmicrosoftmodules.ps1
Last active June 9, 2025 04:09
remove unnecessary old PowerShell modules (Azure, Microsoft.Entra, Microsoft.Graph)
import-module -name PoshSemanticVersion
function Get-LatestVersion
(
[Parameter(Mandatory=$true)]
[string]$moduleName
)
{
$allversions = Get-InstalledModule -Name $moduleName | Sort-Object -Property Version
for($i = 0; $i -lt $allversions.Count; $i++){
@kkamegawa
kkamegawa / profile.ps1
Created March 29, 2025 01:44
Disable telemetry for Microsoft's products
# for WebDriver for Edge
[System.Environment]::SetEnvironmentVariable('MSEDGEDRIVER_TELEMETRY_OPTOUT', '1', [System.EnvironmentVariableTarget]::User)
# for DOTNET SDK
[System.Environment]::SetEnvironmentVariable('DOTNET_CLI_TELEMETRY_OPTOUT', '1', [System.EnvironmentVariableTarget]::User)
# for PowerShell
[System.Environment]::SetEnvironmentVariable('POWERSHELL_TELEMETRY_OPTOUT', '1', [System.EnvironmentVariableTarget]::User)
# for Azure CLI
[System.Environment]::SetEnvironmentVariable('AZURE_CORE_COLLECT_TELEMETRY', '1', [System.EnvironmentVariableTarget]::User)
# for ML.NET CLI
[System.Environment]::SetEnvironmentVariable('MLDOTNET_CLI_TELEMETRY_OPTOUT', '1', [System.EnvironmentVariableTarget]::User)
@kkamegawa
kkamegawa / sync-azmodule.ps1
Last active February 9, 2025 21:15
Sync az module from folder path
$mydocuments = [System.Environment]::GetFolderPath("mydocuments")
$azpath = join-path $mydocuments -childpath PowerShell Modules Az
$versions = get-childItem $azpath | select name
foreach($ver in $versions) {
write-host "version:" + $ver.name
install-module -Name az -RequiredVersion $ver.name -AllowClobber -Force
}
@kkamegawa
kkamegawa / codeql-install-selfhost.yml
Created March 4, 2024 12:06
Install codeql binary for Azure Pipelines selfhost agent
- task: CmdLine@2
condition: eq(variables['Agent.OS'], 'Linux')
displayName: 'prepare CodeQL binary Linux'
inputs:
script: |
curl https://raw.githubusercontent.com/microsoft/GHAzDO-Resources/main/src/agent-setup/codeql-install-ubuntu.sh -o $AGENT_TEMPDIRECTORY/codeql-install.sh
chmod 755 $AGENT_TEMPDIRECTORY/codeql-install.sh
sudo apt install jq -y
$AGENT_TEMPDIRECTORY/codeql-install.sh
- task: CmdLine@2