Skip to content

Instantly share code, notes, and snippets.

Avatar
🌱
Learning && Growing

Deepak Singh Dhami DexterPOSH

🌱
Learning && Growing
View GitHub Profile
View MyPlatform_crd.yaml
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
# name must match the spec fields below, and be in the form: <plural>.<group>
name: myplatforms.contoso.com
spec:
# group name to use for REST API: /apis/<group>/<version>
group: contoso.com
names:
# plural name to be used in the URL: /apis/<group>/<version>/<plural>
View CreateAzDOEnv_Error.ps1
$url = 'https://dev.azure.com/ddhami/BITPro.AzDeploy/_apis/distributedtask/environments'
$cred = Get-Credential -UserName 'vsts' -Message 'Enter AzDO Personal Access Token with privs to create env'
$encodedValue = [Convert]::ToBase64String(
[Text.Encoding]::ASCII.GetBytes(
("{0}:{1}" -f '', $cred.GetNetworkCredential().Password)
)
)
$body = @{
name = 'test-pwsh-env';
@DexterPOSH
DexterPOSH / CreateAzDOEnv.ps1
Last active Apr 13, 2020
Gist showing Pwsh Code snippet to create environments.
View CreateAzDOEnv.ps1
$url = 'https://dev.azure.com/ddhami/BITPro.AzDeploy/_apis/distributedtask/environments'
$cred = Get-Credential -UserName 'vsts' -Message 'Enter AzDO Personal Access Token with privs to create env'
$encodedValue = [Convert]::ToBase64String(
[Text.Encoding]::ASCII.GetBytes(
("{0}:{1}" -f '', $cred.GetNetworkCredential().Password)
)
)
$body = @{
name = 'test-pwsh-env';
View creaAzDOenvError.json
{
"$id": "1",
"innerException": null,
"message": "No api-version was supplied for the \"POST\" request. The version must be supplied either as part of the Accept header (e.g. \"application/json; api-version=1.0\") or as a query parameter (e.g. \"?api-version=1.0\").",
"typeName": "Microsoft.VisualStudio.Services.WebApi.VssVersionNotSpecifiedException, Microsoft.VisualStudio.Services.WebApi",
"typeKey": "VssVersionNotSpecifiedException",
"errorCode": 0,
"eventId": 3000
}
@DexterPOSH
DexterPOSH / 1-hello-world.md
Created Feb 25, 2020
Test content file generated from Hugo CLI
View 1-hello-world.md
title date draft
1 Hello World
2020-02-25 19:23:53 +0530
true

Introduction

Customary "Hello World" program.

@DexterPOSH
DexterPOSH / FetchAssignedPr.ps1
Last active Oct 15, 2019
Code snippet to fetch PRs where a user is assigned as a reviewer
View FetchAssignedPr.ps1
# fetch all the release pipelines metadata for the project
$ProjectName = 'BitPro.AzDeploy'
# Need the UserEmail as this is the unique name
$UserEmail = 'ddhami@foo.com'
# generate a list of User & Groups names to search for in the PR
$IDs = New-Object -TypeName System.Collections.ArrayList
$UserObject = az devops user show --user $UserEmail | ConvertFrom-Json
$IDs.Add($UserObject.Id)
@DexterPOSH
DexterPOSH / azDevopsReleaseTaskAudit.ps1
Last active Oct 10, 2019
This PowerShell script lists out how to use Az CLI's DevOps extension to walk through the release definitions in a project and check for a specific taskId.
View azDevopsReleaseTaskAudit.ps1
# Set the PAT as an Environment variable, put this in your profile.
# I only use the CLI for read operations so make sure you grant the PAT only that access
$env:AZURE_DEVOPS_EXT_PAT = "<Insert PAT Token here>"
# configure the defaults for the Az DevOps extension for Az CLI to use
az devops configure --defaults organization=https://dev.azure.com/dexterposh project=Test.Project
# see the configured defaults
az devops configure --list
View Get-SCCMDeviceInfo.ps1
function Get-SCCMDeviceInfo
{
[CmdletBinding(DefaultParameterSetName='Computer')]
[OutputType([PSObject])]
Param
(
# Specify the Package IDs which need to be removed from the DP
[Parameter(Mandatory,
ParameterSetName="Computer",
@DexterPOSH
DexterPOSH / auth.go
Created May 18, 2019
getAuthorizer() method for settings struct
View auth.go
func (settings settings) getAuthorizer() (autorest.Authorizer, error) {
//1.Client Credentials
if settings.clientSecret != "" {
config := NewClientCredentialsConfig(settings.clientID, settings.clientSecret, settings.tenantID)
config.AADEndpoint = settings.environment.ActiveDirectoryEndpoint
config.Resource = settings.resource
return config.Authorizer()
}
//2. Client Certificate