26 changed files
.vscode | ||
launch.json + | ||
settings.json + | ||
tasks.json + | ||
Build | ||
build.ps1 + | ||
build.psake.ps1 + | ||
deploy.psdeploy.ps1 + | ||
Examples | ||
Export-CIEdge_Controller.ps1 + | ||
Get-CIVMPrice_Controller.ps1 + | ||
PSvCloud | ||
Private | ||
Get-EqualOrNextHighestNumber.ps1 + | ||
Test-CIConnection.ps1 + | ||
Public | ||
Catalog | ||
Set-Media.ps1 + | ||
Edge | ||
Get-CIEdge.ps1 + | ||
Get-CIEdgeSecurityCheck.ps1 + | ||
Get-CIEdgeView.ps1 + | ||
Get-CIEdgeXML.ps1 + | ||
VM | ||
Get-CIVMPrice.ps1 + | ||
PSvCloud.psd1 + | ||
PSvCloud.psm1 + | ||
Tests | ||
000-Module.Tests.ps1 + | ||
001-Connection.Tests.ps1 + | ||
Get-CIEdge.Tests.ps1 + | ||
.gitignore + | ||
azure-pipelines.yml + | ||
LICENSE + | ||
PSScriptAnalyzerSettings.psd1 + | ||
README.md | ||
Add comment 1 Plus {
Add comment 2 Plus "version": "0.2.0",
Add comment 3 Plus "configurations": [
Add comment 4 Plus {
Add comment 5 Plus "type": "PowerShell",
Add comment 6 Plus "request": "launch",
Add comment 7 Plus "name": "PowerShell Launch Current File",
Add comment 8 Plus "script": "${file}",
Add comment 9 Plus "args": [
Add comment 10 Plus "-NoProfile",
Add comment 11 Plus "-ExecutionPolicy",
Add comment 12 Plus "Bypass"
Add comment 13 Plus ],
Add comment 14 Plus "cwd": "${file}"
Add comment 15 Plus }
Add comment 16 Plus ]
Add comment 17 Plus }
Add comment 1 Plus // Place your settings in this file to overwrite default and user settings.
Add comment 2 Plus {
Add comment 3 Plus // TODO: add project settings like PowerShell code formatting rules
Add comment 4 Plus }
Add comment 5 Plus
Add comment 1 Plus // Available variables which can be used inside of strings.
Add comment 2 Plus // ${workspaceRoot}: the root folder of the team
Add comment 3 Plus // ${file}: the current opened file
Add comment 4 Plus // ${relativeFile}: the current opened file relative to workspaceRoot
Add comment 5 Plus // ${fileBasename}: the current opened file's basename
Add comment 6 Plus // ${fileDirname}: the current opened file's dirname
Add comment 7 Plus // ${fileExtname}: the current opened file's extension
Add comment 8 Plus // ${cwd}: the current working directory of the spawned process
Add comment 9 Plus {
Add comment 10 Plus // See https://go.microsoft.com/fwlink/?LinkId=733558
Add comment 11 Plus // for the documentation about the tasks.json format
Add comment 12 Plus "version": "2.0.0",
Add comment 13 Plus
Add comment 14 Plus // Start PowerShell
Add comment 15 Plus "windows": {
Add comment 16 Plus "command": "${env:windir}/System32/WindowsPowerShell/v1.0/powershell.exe",
Add comment 17 Plus "args": [
Add comment 18 Plus "-NoProfile",
Add comment 19 Plus "-ExecutionPolicy",
Add comment 20 Plus "Bypass"
Add comment 21 Plus ]
Add comment 22 Plus },
Add comment 23 Plus "linux": {
Add comment 24 Plus "command": "/usr/bin/powershell",
Add comment 25 Plus "args": [
Add comment 26 Plus "-NoProfile"
Add comment 27 Plus ]
Add comment 28 Plus },
Add comment 29 Plus "osx": {
Add comment 30 Plus "command": "/usr/local/bin/powershell",
Add comment 31 Plus "args": [
Add comment 32 Plus "-NoProfile"
Add comment 33 Plus ]
Add comment 34 Plus },
Add comment 35 Plus
Add comment 36 Plus // Associate with test task runner
Add comment 37 Plus "tasks": [{
Add comment 38 Plus "taskName": "Analyze",
Add comment 39 Plus
Add comment 40 Plus "suppressTaskName": true,
Add comment 41 Plus "showOutput": "always",
Add comment 42 Plus "args": [
Add comment 43 Plus "Write-Host 'Running Analyze Task...'; & .\\Build\\build.ps1 -Task Analyze;",
Add comment 44 Plus "Write-Host \"`nCompleted Analyze task in task runner.\""
Add comment 45 Plus ]
Add comment 46 Plus },
Add comment 47 Plus {
Add comment 48 Plus "taskName": "Test",
Add comment 49 Plus "suppressTaskName": true,
Add comment 50 Plus "isTestCommand": true,
Add comment 51 Plus "showOutput": "always",
Add comment 52 Plus "args": [
Add comment 53 Plus "Write-Host 'Running Test Task...'; & .\\Build\\build.ps1 -Task Test;",
Add comment 54 Plus "Write-Host \"`nCompleted Test task in task runner.\""
Add comment 55 Plus ],
Add comment 56 Plus "problemMatcher": [{
Add comment 57 Plus "owner": "powershell",
Add comment 58 Plus "fileLocation": ["absolute"],
Add comment 59 Plus "severity": "error",
Add comment 60 Plus "pattern": [{
Add comment 61 Plus "regexp": "^\\s*(\\[-\\]\\s*.*?)(\\d+)ms\\s*$",
Add comment 62 Plus "message": 1
Add comment 63 Plus },
Add comment 64 Plus {
Add comment 65 Plus "regexp": "^\\s+at\\s+[^,]+,\\s*(.*?):\\s+line\\s+(\\d+)$",
Add comment 66 Plus "file": 1,
Add comment 67 Plus "line": 2
Add comment 68 Plus }
Add comment 69 Plus ]
Add comment 70 Plus }]
Add comment 71 Plus },
Add comment 72 Plus {
Add comment 73 Plus "taskName": "Build",
Add comment 74 Plus "suppressTaskName": true,
Add comment 75 Plus "isBuildCommand": true,
Add comment 76 Plus "args": [
Add comment 77 Plus "Write-Host 'Running Build Task...'; & .\\Build\\build.ps1 -Task Build;",
Add comment 78 Plus "Write-Host \"`nCompleted Build task in task runner.\""
Add comment 79 Plus ]
Add comment 80 Plus }
Add comment 81 Plus ]
Add comment 82 Plus }
Add comment 83 Plus
Add comment 1 Plus param ($Task = 'Default')
Add comment 2 Plus
Add comment 3 Plus $global:VerbosePreference = "SilentlyContinue"
Add comment 4 Plus
Add comment 5 Plus # Grab nuget bits, install modules, set build variables, start build.
Add comment 6 Plus Get-PackageProvider -Name 'NuGet' -ForceBootstrap | Out-Null
Add comment 7 Plus
Add comment 8 Plus # Install modules if required
Add comment 9 Plus $ModNames = @('Psake', 'PSDeploy', 'BuildHelpers', 'PSScriptAnalyzer', 'VMware.VimAutomation.Cloud')
Add comment 10 Plus foreach ($ModName in $ModNames) {
Add comment 11 Plus if (-not (Get-Module -Name $ModName -ListAvailable)) {
Add comment 12 Plus Write-Verbose "$ModName module not installed. Installing from PSGallery..."
Add comment 13 Plus Install-Module -Name $ModName -Force -AllowClobber -Scope 'CurrentUser' > $null
Add comment 14 Plus }
Add comment 15 Plus
Add comment 16 Plus if (-not (Get-Module -Name $ModName)) {
Add comment 17 Plus Import-Module -Name $ModName -Force
Add comment 18 Plus }
Add comment 19 Plus }
Add comment 20 Plus
Add comment 21 Plus # Target latest version of Pester as older versions are bundled with OS
Add comment 22 Plus if (-not (Get-Module -Name 'Pester' -ListAvailable | Where-Object {$_.Version -match '^4.'})) {
Add comment 23 Plus Install-Module 'Pester' -MinimumVersion '4.4.2' -Force -AllowClobber -Scope 'CurrentUser' -SkipPublisherCheck -ErrorAction 'Stop'
Add comment 24 Plus }
Add comment 25 Plus if (-not (Get-Module -Name 'Pester')) {
Add comment 26 Plus Import-Module -Name 'Pester' -Force
Add comment 27 Plus }
Add comment 28 Plus
Add comment 29 Plus Set-BuildEnvironment
Add comment 30 Plus
Add comment 31 Plus Invoke-psake -buildFile $ENV:BHProjectPath\Build\build.psake.ps1 -taskList $Task -nologo
Add comment 32 Plus exit ( [int]( -not $psake.build_success ) )
Add comment 33 Plus
Add comment 1 Plus # PSake makes variables declared here available in other scriptblocks
Add comment 2 Plus Properties {
Add comment 3 Plus $ProjectRoot = $ENV:BHProjectPath
Add comment 4 Plus if (-not $ProjectRoot) {
Add comment 5 Plus $ProjectRoot = $PSScriptRoot
Add comment 6 Plus }
Add comment 7 Plus
Add comment 8 Plus $Timestamp = Get-Date -UFormat "%Y%m%d-%H%M%S"
Add comment 9 Plus $PSVersion = $PSVersionTable.PSVersion.Major
Add comment 10 Plus $lines = '----------------------------------------------------------------------'
Add comment 11 Plus
Add comment 12 Plus $Verbose = @{}
Add comment 13 Plus if ($ENV:BHCommitMessage -match "!verbose") {
Add comment 14 Plus $Verbose = @{Verbose = $True}
Add comment 15 Plus }
Add comment 16 Plus
Add comment 17 Plus # Pester
Add comment 18 Plus $TestRootDir = "$ProjectRoot\Tests"
Add comment 19 Plus $TestScripts = Get-ChildItem "$ProjectRoot\Tests\*Tests.ps1"
Add comment 20 Plus $TestFile = "TestResults_PS$PSVersion`_$TimeStamp.xml"
Add comment 21 Plus
Add comment 22 Plus # Script Analyzer
Add comment 23 Plus [ValidateSet('Error', 'Warning', 'Any', 'None')]
Add comment 24 Plus $ScriptAnalysisFailBuildOnSeverityLevel = 'None'
Add comment 25 Plus $ScriptAnalyzerSettingsPath = "$ProjectRoot\PSScriptAnalyzerSettings.psd1"
Add comment 26 Plus }
Add comment 27 Plus
Add comment 28 Plus Task 'Default' -Depends 'Test'
Add comment 29 Plus
Add comment 30 Plus Task 'Init' {
Add comment 31 Plus $lines
Add comment 32 Plus Set-Location $ProjectRoot
Add comment 33 Plus "Build System Details:"
Add comment 34 Plus Get-Item ENV:BH*
Add comment 35 Plus "`n"
Add comment 36 Plus }
Add comment 37 Plus
Add comment 38 Plus Task 'Analyze' -Depends 'Init' {
Add comment 39 Plus
Add comment 40 Plus $Results = Invoke-ScriptAnalyzer -Path $ENV:BHModulePath -Recurse -Settings $ScriptAnalyzerSettingsPath -Verbose:$VerbosePreference
Add comment 41 Plus $Results | Select-Object 'RuleName', 'Severity', 'ScriptName', 'Line', 'Message' | Format-List
Add comment 42 Plus
Add comment 43 Plus switch ($ScriptAnalysisFailBuildOnSeverityLevel) {
Add comment 44 Plus
Add comment 45 Plus 'None' {
Add comment 46 Plus return
Add comment 47 Plus }
Add comment 48 Plus 'Error' {
Add comment 49 Plus Assert -conditionToCheck (
Add comment 50 Plus ($Results | Where-Object 'Severity' -eq 'Error').Count -eq 0
Add comment 51 Plus ) -failureMessage 'One or more ScriptAnalyzer errors were found. Build cannot continue!'
Add comment 52 Plus }
Add comment 53 Plus 'Warning' {
Add comment 54 Plus Assert -conditionToCheck (
Add comment 55 Plus ($Results | Where-Object {
Add comment 56 Plus $_.Severity -eq 'Warning' -or $_.Severity -eq 'Error'
Add comment 57 Plus }).Count -eq 0) -failureMessage 'One or more ScriptAnalyzer warnings were found. Build cannot continue!'
Add comment 58 Plus }
Add comment 59 Plus default {
Add comment 60 Plus Assert -conditionToCheck ($analysisResult.Count -eq 0) -failureMessage 'One or more ScriptAnalyzer issues were found. Build cannot continue!'
Add comment 61 Plus }
Add comment 62 Plus
Add comment 63 Plus }
Add comment 64 Plus
Add comment 65 Plus }
Add comment 66 Plus
Add comment 67 Plus Task 'Test' -Depends 'Analyze' {
Add comment 68 Plus $lines
Add comment 69 Plus "`nSTATUS: Testing with PowerShell $PSVersion"
Add comment 70 Plus
Add comment 71 Plus # Gather test results. Store them in a variable and file
Add comment 72 Plus $TestFilePath = Join-Path -Path $ProjectRoot -ChildPath $TestFile
Add comment 73 Plus $TestResults = Invoke-Pester -Script $TestScripts -PassThru -OutputFormat 'NUnitXml' -OutputFile $TestFilePath -PesterOption @{IncludeVSCodeMarker = $true}
Add comment 74 Plus
Add comment 75 Plus # Upload test results to Appveyor
Add comment 76 Plus if ($ENV:BHBuildSystem -eq 'AppVeyor') {
Add comment 77 Plus Add-TestResultToAppVeyor -TestFile $TestFilePath
Add comment 78 Plus }
Add comment 79 Plus
Add comment 80 Plus Remove-Item $TestFilePath -Force -ErrorAction 'SilentlyContinue'
Add comment 81 Plus
Add comment 82 Plus # Fail build if any tests fail
Add comment 83 Plus if ($TestResults.FailedCount -gt 0) {
Add comment 84 Plus Write-Error "Failed '$($TestResults.FailedCount)' tests, build failed"
Add comment 85 Plus }
Add comment 86 Plus "`n"
Add comment 87 Plus }
Add comment 88 Plus
Add comment 89 Plus Task 'Build' -Depends 'Test' {
Add comment 90 Plus $lines
Add comment 91 Plus
Add comment 92 Plus # Load the module, read the exported functions, update the psd1 FunctionsToExport
Add comment 93 Plus Set-ModuleFunctions -Name $env:BHPSModuleManifest
Add comment 94 Plus
Add comment 95 Plus # Bump the module version
Add comment 96 Plus try {
Add comment 97 Plus $Version = Get-NextPSGalleryVersion -Name $env:BHProjectName -ErrorAction 'Stop'
Add comment 98 Plus Update-Metadata -Path $env:BHPSModuleManifest -PropertyName 'ModuleVersion' -Value $Version -ErrorAction 'Stop'
Add comment 99 Plus }
Add comment 100 Plus catch {
Add comment 101 Plus "Failed to update version for '$env:BHProjectName': $_.`nContinuing with existing version"
Add comment 102 Plus }
Add comment 103 Plus }
Add comment 104 Plus
Add comment 105 Plus Task 'Deploy' -Depends 'Build' {
Add comment 106 Plus $lines
Add comment 107 Plus
Add comment 108 Plus $Params = @{
Add comment 109 Plus Path = "$ProjectRoot"
Add comment 110 Plus Force = $true
Add comment 111 Plus Recurse = $false
Add comment 112 Plus }
Add comment 113 Plus Invoke-PSDeploy @Verbose @Params
Add comment 114 Plus }
Add comment 115 Plus
Add comment 1 Plus # Config file for PSDeploy
Add comment 2 Plus # Set-BuildEnvironment from BuildHelpers module has populated ENV:BHModulePath and related variables
Add comment 3 Plus # Publish to gallery with a few restrictions
Add comment 4 Plus if (
Add comment 5 Plus $env:BHPSModulePath -and
Add comment 6 Plus $env:BHBuildSystem -ne 'Unknown' -and
Add comment 7 Plus $env:BHBranchName -eq "master" -and
Add comment 8 Plus $env:BHCommitMessage -match '!deploy'
Add comment 9 Plus ) {
Add comment 10 Plus Deploy Module {
Add comment 11 Plus By PSGalleryModule {
Add comment 12 Plus FromSource $ENV:BHPSModulePath
Add comment 13 Plus To PSGallery
Add comment 14 Plus WithOptions @{
Add comment 15 Plus ApiKey = $ENV:NugetApiKey
Add comment 16 Plus }
Add comment 17 Plus }
Add comment 18 Plus }
Add comment 19 Plus }
Add comment 20 Plus else {
Add comment 21 Plus "Skipping deployment: To deploy, ensure that...`n" +
Add comment 22 Plus "`t* You are in a known build system (Current: $ENV:BHBuildSystem)`n" +
Add comment 23 Plus "`t* You are committing to the master branch (Current: $ENV:BHBranchName) `n" +
Add comment 24 Plus "`t* Your commit message includes !deploy (Current: $ENV:BHCommitMessage)" |
Add comment 25 Plus Write-Host
Add comment 26 Plus }
Add comment 27 Plus
Add comment 28 Plus # Publish to AppVeyor if we're in AppVeyor
Add comment 29 Plus if ($env:BHPSModulePath -and $env:BHBuildSystem -eq 'AppVeyor') {
Add comment 30 Plus Deploy DeveloperBuild {
Add comment 31 Plus By AppVeyorModule {
Add comment 32 Plus FromSource $ENV:BHPSModulePath
Add comment 33 Plus To AppVeyor
Add comment 34 Plus WithOptions @{
Add comment 35 Plus Version = $env:APPVEYOR_BUILD_VERSION
Add comment 36 Plus }
Add comment 37 Plus }
Add comment 38 Plus }
Add comment 39 Plus }
Add comment 40 Plus
Export-CIEdge_Controller.ps1
/Examples/Export-CIEdge_Controller.ps1/Examples/Export-CIEdge_Controller.ps1
Get-CIVMPrice_Controller.ps1
/Examples/Get-CIVMPrice_Controller.ps1/Examples/Get-CIVMPrice_Controller.ps1
Get-EqualOrNextHighestNumber.ps1
/PSvCloud/Private/Get-EqualOrNextHighestNumber.ps1/PSvCloud/Private/Get-EqualOrNextHighestNumber.ps1
Test-CIConnection.ps1
/PSvCloud/Private/Test-CIConnection.ps1/PSvCloud/Private/Test-CIConnection.ps1
Get-CIEdgeSecurityCheck.ps1
/PSvCloud/Public/Edge/Get-CIEdgeSecurityCheck.ps1/PSvCloud/Public/Edge/Get-CIEdgeSecurityCheck.ps1
Get-CIEdgeView.ps1
/PSvCloud/Public/Edge/Get-CIEdgeView.ps1/PSvCloud/Public/Edge/Get-CIEdgeView.ps1