-
-
Save s4parke/d456d513275077802be99a56c51dc0cc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# import module | |
Import-Module psAzD | |
# set default parameters | |
$params = @{ | |
Organization = "myOrganization" | |
Project = "Test" | |
PersonalAccessToken = "Azure DevOps Personal Access Token here" | |
} | |
Set-AzDDefaultParameters @params | |
# 1) get all organizations | |
$orgs = Get-AzDOrganizationList | |
$orgs | |
# 2) get all projects | |
$projects = Get-AzDCoreProjects | |
$projects.value | |
# 3) get all processes | |
$processes = Get-AzDCoreProcesses | |
$processes.value | |
# 4) get list of users | |
$users = Get-AzDMEMUserEntitlements -Top 500 | |
$users | |
# list members | |
$users.members | |
# get users | |
$users.members.user | |
# list display name | |
$users.members.user.displayName | |
# get more users | |
(Get-AzDMEMUserEntitlements -Top 500).members.user.displayName | |
# 5) get applied policies | |
$policies = Get-AzDPolicyConfigurations | |
$policies | |
# get policy for a particular type | |
$typeId = $policies.value[0].type.id | |
(Get-AzDPolicyConfigurations -PolicyType $typeId).value | |
# 6) get list of available repositories | |
$repos = Get-AzDGitRepositories | |
$repos.value.name | |
# 7) get list of pull requests | |
$pullRequests = Get-AzDGitPullRequestsByProject -Top 500 -Status completed | |
$pullRequests | |
# 8) get list of licenses | |
$userSummary = Get-AzDMEMUserEntitlementSummary | |
$userSummary.licenses | |
$userSummary.defaultAccessLevel | |
$userSummary.availableAccessLevels | |
# 9) policy evaluations | |
# select Test project | |
$myProject = $projects.value | Where-Object {$_.name -eq "Test"} | |
$policyEval = Get-AzDPolicyEvaluations ` | |
-ProjectId $myProject.id ` | |
-PullRequestId $pullRequests.value[0].pullRequestId | |
$policyEval.value | |
# get policy evaluation details | |
$policyEval.value | ForEach-Object { | |
$_.evaluationId | Get-AzDPolicyEvaluation | |
} | |
$policyEval.value | ForEach-Object { | |
$_.evaluationId | Get-AzDPolicyEvaluation | Where-Object {$_.status -eq "approved"} | |
} | |
# 10) get list of accounts that you have access to | |
$myId = $users.members | Where-Object {$_.user.displayName -eq "yourusername"} | |
$myId.id | Get-AzDAccounts | |
# 11) Get a list of builds | |
$builds = Get-AzDBuilds -Top 1000 | |
$builds | |
# get specific builds | |
$ids = @(1124, 246, 3845, 9735, 73553, 436758, 5763, 535, 3653) | |
$ids | Get-AzDBuilds | |
# get a single build | |
$ids[0] | Get-AzDBuild | |
# 12) get build logs | |
$logs = $ids[0] | Get-AzDBuildLogs | |
$logs.value | |
# 13) get build log | |
Get-AzDBuildLog ` | |
-LogId 14 ` | |
-BuildId $ids[0] ` | |
-StartLine 0 ` | |
-EndLine 50 | |
# 14) get list of releases | |
$releases = Get-AzDReleases | |
$releases.value | |
# get specific releases | |
$relIds = $releases.value.id | Select-Object -First 10 | |
$relIds | Get-AzDReleases | |
# get a release | |
$relIds[0] | Get-AzDRelease | |
# 15) get release logs | |
Get-AzDReleaseLogs -ReleaseId $relIds[0] -FilePath .\logs.zip | |
# 16) get work item | |
882 | Get-AzDWorkItem | |
# 17) get wikis | |
$wikis = Get-AzDWikis | |
$wikis.value | |
# get a wiki with path | |
$wikis.value.id | Get-AzDWiki | |
# get wiki page | |
Get-AzDWikiPage -WikiIdentifier $wikis.value.id -Path "/" -RecursionLevel full -IncludeContent | |
$wikiPage = Get-AzDWikiPage ` | |
-WikiIdentifier $wikis.value.id ` | |
-Path "/My Project Documentation/First Path" ` | |
-RecursionLevel full ` | |
-IncludeContent | |
$wikiPage.content | Set-Content .\wikiPage.md | |
Get-AzDExtension -ExtensionId ws-bolt -PublisherId whitesource | |
$build = Get-AzDBuild 8493 | |
Get-AzDGitCommit -CommitId $build.triggerInfo.'ci.sourceSha' -RepositoryId $build.triggerInfo.'ci.triggerRepository' | |
# Create new repository | |
"MyRepository" | New-AzDGitRepository | |
# Create new project | |
# By default scrum project will be created. You can view the cmdlet help file to know more. | |
New-AzDCoreProject -ProjectName Test | |
# Create new team | |
New-AzDCoreTeam -ProjectId "project id" -TeamName "My New Team" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment