Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"action-input-default-values": [],
"base-action-name": "Sync OS versions AD to CB",
"dialog-message": "",
"enabled": "True",
"extra-classes": "fas fa-bolt",
"label": "Sync OS versions AD to CB",
"requires-approval": "False",
"sequence": null,
"submit-button-label": "Vaya!"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
$ErrorActionPreference = "Stop"

Write-Host "Running the PowerShell Plug-in code"

$cb_api_url = "{{ cb_api_url }}"
$token = "{{ plugin_api_token }}"
$headers = @{
'Authorization' = "Bearer " + $token
}

{% for server in servers %}
Write-Host "Getting OS version info from AD for {{ server.hostname }}"
$adcomputer = Get-ADComputer -Identity "{{ server.hostname }}" -Properties OperatingSystem, OperatingSystemServicePack, OperatingSystemVersion

$body = @{
parameters = @{
os_version = $adcomputer.OperatingSystem
}
}
$json_payload = $body | ConvertTo-Json
Write-Host "Setting the os_version parameter on '{{ server.hostname }}' to " $body.parameters.os_version
Invoke-RestMethod -Method Post -Uri $cb_api_url"/api/v2/servers/{{ server.id }}/parameters/" -Headers $headers -Body $json_payload -ContentType 'application/json'
{% endfor %}

Write-Host "Fetching a list of environments from API v3"
$environments = Invoke-RestMethod -Uri $cb_api_url"/api/v3/cmp/environments/" -Headers $headers
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"description": "",
"execution-timeout": 120,
"max-retries": 0,
"name": "Sync OS versions AD to CB",
"resource-technologies": [],
"script-filename": "cb_plugin_1604344305994213_UGgl0a7.py",
"shared": "False",
"target-os-families": [],
"type": "PowerShell Plug-in"
}