diff --git a/actions/powershell_plugins/sync_os_versions_ad_to_cb/sync_os_versions_ad_to_cb.json b/actions/powershell_plugins/sync_os_versions_ad_to_cb/sync_os_versions_ad_to_cb.json new file mode 100644 index 00000000..50dfcefd --- /dev/null +++ b/actions/powershell_plugins/sync_os_versions_ad_to_cb/sync_os_versions_ad_to_cb.json @@ -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!" +} \ No newline at end of file diff --git a/actions/powershell_plugins/sync_os_versions_ad_to_cb/sync_os_versions_ad_to_cb/cb_plugin_1604344305994213_UGgl0a7.py b/actions/powershell_plugins/sync_os_versions_ad_to_cb/sync_os_versions_ad_to_cb/cb_plugin_1604344305994213_UGgl0a7.py new file mode 100644 index 00000000..78cd9cb8 --- /dev/null +++ b/actions/powershell_plugins/sync_os_versions_ad_to_cb/sync_os_versions_ad_to_cb/cb_plugin_1604344305994213_UGgl0a7.py @@ -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 \ No newline at end of file diff --git a/actions/powershell_plugins/sync_os_versions_ad_to_cb/sync_os_versions_ad_to_cb/sync_os_versions_ad_to_cb.json b/actions/powershell_plugins/sync_os_versions_ad_to_cb/sync_os_versions_ad_to_cb/sync_os_versions_ad_to_cb.json new file mode 100644 index 00000000..b8494a6b --- /dev/null +++ b/actions/powershell_plugins/sync_os_versions_ad_to_cb/sync_os_versions_ad_to_cb/sync_os_versions_ad_to_cb.json @@ -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" +} \ No newline at end of file