Create-DevOpsProject.psm1
#Verificando dependencias de modulos Function Check-AzDeps { Write-Host "Check modules dependencies, please wait..." Write-Host $module1 = Get-Module -ListAvailable -Name Az.Accounts $module2 = (Get-WmiObject win32_product | Where-Object {$_.name -eq "Microsoft Azure CLI"}).caption if ($module1){ Write-Host "Az.Accounts module already installed!!" -ForegroundColor Green write-host }else{ Write-Host "Downloading Az.Accounts module, please wait..." start-sleep 2 Install-Module az.accounts -Force -Verbose -AllowClobber -Confirm:$false } if ($module2){ Write-Host "AzureCLI already installed!!" -ForegroundColor Green }else{ Write-Host "Downloading and installing Azure CLI application, please wait..." -ForegroundColor Green Start-Sleep 3 Invoke-WebRequest -Uri https://aka.ms/installazurecliwindows -OutFile .\AzureCLI.msi; ` Start-Process msiexec.exe -Wait -ArgumentList '/I AzureCLI.msi /quiet' } Write-Host Write-Host "Checking the 'Azure Devops' extesion......" Write-Host az extension add --name azure-devops Write-Host } function Create-DevopsProject { [CmdletBinding()] Param( [ValidateSet('git','tfvc')] [Parameter( Mandatory = $true, HelpMessage = "Enter Type of Repository", Position = 1 )][String]$Repository, [ValidateSet('private','public')] [Parameter( Mandatory = $true, HelpMessage = "Enter Type of project view", Position = 1 )][String]$typeofview, [Parameter(Mandatory = $true)]$Projectname, [Parameter(Mandatory = $true)]$Description, [Parameter(Mandatory = $true)]$OrganizationName ) az devops project create --description $Description ` --visibility $typeofview ` --name "$Projectname" ` --organization "https://$OrganizationName.visualstudio.com" ` -s $Repository ` --open } |