[Index]
MSExchangeOnline_powershell_envelope
Model ref.: data/MSExchangeOnline_powershell_envelope
The full URL would include the host-proxy name: https://[host-proxy].
Variables are enclosed in square brackets.
{ "$schema": "http://json-schema.org/draft-03/schema", "type": "object", "properties": { "name": { "required": true, "type": "string", "title": "Name" }, "envelope": { "required": true, "type": "string", "title": "Envelope" } }, "schema_version": "1.0.0" }
Task | Call | URL | Parameters | Response |
---|---|---|---|---|
Get the GUI Add form. | GET | /api/data/MSExchangeOnline_powershell_envelope/add/ |
|
The GUI Add form of data/MSExchangeOnline_powershell_envelope as JSON |
The API call to the /add/ URL can only be made from a hierarchy that allows the model type to be added. The actions in the response shows the url for the POST API call to create an instance.
Task | Call | URL | Parameters | Payload |
---|---|---|---|---|
Create | POST | /api/data/MSExchangeOnline_powershell_envelope | hierarchy=[hierarchy] |
|
tool/Transaction/[trans pkid]to inspect the created resource and its instance pkid.
Task | Call | URL | Parameters | Payload |
---|---|---|---|---|
Bulk delete [pkid1],[pkid2]... | DELETE | /api/data/MSExchangeOnline_powershell_envelope/ | hierarchy=[hierarchy] | {"hrefs":["/api/data/MSExchangeOnline_powershell_envelope/[pkid1]", "/api/data/MSExchangeOnline_powershell_envelope/[pkid2]", ...]} |
GET http://[host-proxy]/api/data/MSExchangeOnline_powershell_envelope/?hierarchy=[hierarchy]&format=json
Task | Call | URL | Parameters | Response |
---|---|---|---|---|
Bulk Modify | GET | /api/data/MSExchangeOnline_powershell_envelope/bulk_update/?schema=&schema_rules=true |
|
|
Task | Call | URL | Parameters | Payload |
---|---|---|---|---|
Bulk Modify | POST | /api/data/MSExchangeOnline_powershell_envelope/bulk_update/ |
|
For example: {"data":{"name":"value"}, "meta":{}, "request_meta":{ "hrefs":["/api/v0/data/MSExchangeOnline_powershell_envelope/[pkid1]", "/api/v0/data/MSExchangeOnline_powershell_envelope/[pkid2]",...]}} |
GET http://[host-proxy]/api/data/MSExchangeOnline_powershell_envelope/?hierarchy=[hierarchy]&format=json
Task | Call | URL | Parameters | Payload |
---|---|---|---|---|
Get a selected [export_format] of the schema and instances [pkid1], [pkid2],... of data/MSExchangeOnline_powershell_envelope; optionally with tag_version at [version] and Configuration Template as [configtemplate]. | POST | /api/data/MSExchangeOnline_powershell_envelope/export/ |
|
{ "hrefs":["/api/data/MSExchangeOnline_powershell_envelope/[pkid1]", "/api/data/MSExchangeOnline_powershell_envelope/[pkid2]",...]}} |
For export_format=json, the response is a time stamped zip file of data in JSON as in the system database. Item properties such as strings that are empty or Boolean values that are not set, are not included. The filename in the response is of the format as the example:
Content-Disposition: attachment; filename=export_2013-05-17_14:20:19.186444.json.zip Content-Language:en Content-Type:application/x-zip
For export_format=raw_xlsx, the response is a MS Excel spreadsheet with columns corresponding to the JSON format export and a response filename format:
Content-Disposition: attachment; filename=<resource_type>_<resource_name>_exportedsheet_CCYY-MM-DD_HH-MM-SS.xlsx Content-Language:en Content-Type:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
For export_format=xlsx, the response is a MS Excel spreadsheet, arranged by any Field Display Policies that apply. The columns correspond with those of a Bulk Load Template export sheet. The response filename format is:
Content-Disposition: attachment; filename=<resource_type>_<resource_name>_exportedsheet_formatted_CCYY-MM-DD_HH-MM-SS.xlsx Content-Language:en Content-Type:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
The XLSX format can be used to bulk load instances of data/MSExchangeOnline_powershell_envelope and the JSON format can be used to import instances of data/MSExchangeOnline_powershell_envelope.
GET http://[host-proxy]/api/data/MSExchangeOnline_powershell_envelope/?hierarchy=[hierarchy]
Task | Call | URL | Parameters | Response |
---|---|---|---|---|
Get a compressed format of the Bulk Load spreadsheet template for data/MSExchangeOnline_powershell_envelope | POST | /api/data/MSExchangeOnline_powershell_envelope/export_bulkload_template/ |
|
The response is an attachment of the format: filetype_bulkloadsheet.xlsx.gz |
Task | Call | URL | Parameters | Response |
---|---|---|---|---|
Tag | PATCH | /api/data/MSExchangeOnline_powershell_envelope/+tag/ |
|
Task | Call | URL | Parameters | Response |
---|---|---|---|---|
Tag Version | PATCH | /api/data/MSExchangeOnline_powershell_envelope/+tag_version/ |
|
Task | Call | URL | Parameters | Response |
---|---|---|---|---|
Configuration Template | GET | /api/data/MSExchangeOnline_powershell_envelope/configuration_template/ | hierarchy=[hierarchy] |
|
POST http://[host-proxy]/api/data/ConfigurationTemplate/?hierarchy=[hierarchy]
Task | Call | URL | Parameters | Response |
---|---|---|---|---|
Field Display Policy | GET | /api/data/MSExchangeOnline_powershell_envelope/field_display_policy/ | hierarchy=[hierarchy] |
|
POST http://[host-proxy]/api/data/FieldDisplayPolicy/?hierarchy=[hierarchy]
Task | Call | URL | Parameters | Response |
---|---|---|---|---|
Migration Template | GET | /api/data/MSExchangeOnline_powershell_envelope/migration/ |
|
Task | Call | URL | Parameters | Response |
---|---|---|---|---|
List | GET | /api/data/MSExchangeOnline_powershell_envelope/ |
|
The data/MSExchangeOnline_powershell_envelope schema and all instances as JSON. |
(The list will return 0 to 3 data/MSExchangeOnline_powershell_envelope instances)
{ "pagination": { "skip": 0, "limit": 3, "maximum_limit": 2000, "total": 1, "total_limit": null, "order_by": "name", "direction": "asc", "current": "/api/data/MSExchangeOnline_powershell_envelope/?skip=0&limit=3&order_by=name&direction=asc&traversal=down" }, "operations": [ "field_display_policy", "update", "help", "remove", "move", "add", "export", "list", "configuration_template", "get", "bulk_update_form", "migration", "transform", "export_bulkload_template" ], "meta": { "model_type": "data/MSExchangeOnline_powershell_envelope", "summary_attrs": [ { "name": "name", "title": "Name" }, { "name": "hierarchy_friendly_name", "title": "Located At", "allow_filtering": true } ], "tagged_versions": [], "tags": [], "title": "", "business_key": { "hierarchy": true, "unique": [ "name" ] }, "api_version": "21.2", "cached": true, "references": { "children": [], "parent": [ { "href": "/api/data/HierarchyNode/6t0ggef2c0deab00hb595101", "pkid": "6t0ggef2c0deab00hb595101" } ], "device": [ { "href": "", "pkid": "" } ], "foreign_key": [] }, "model_specific_actions": [ "add", "bulk_update_form", "clone", "configuration_template", "export", "export_bulkload_template", "field_display_policy", "get", "help", "list", "migration", "transform", "remove", "tag", "tag_version", "update" ], "schema_version": "1.0.0", "actions": [ { "add": { "method": "GET", "class": "add", "href": "/api/data/MSExchangeOnline_powershell_envelope/add/?hierarchy=[hierarchy]", "support_async": false, "title": "Add" } }, { "remove": { "method": "DELETE", "class": "delete", "href": "/api/data/MSExchangeOnline_powershell_envelope/?hierarchy=[hierarchy]", "support_async": true, "title": "Delete" } }, { "bulk_update_form": { "method": "GET", "class": "update", "href": "/api/data/MSExchangeOnline_powershell_envelope/bulk_update/?hierarchy=[hierarchy]&schema=&schema_rules=true", "support_async": false, "title": "Bulk Modify" } }, { "export": { "method": "POST", "class": "export", "href": "/api/data/MSExchangeOnline_powershell_envelope/export/?hierarchy=[hierarchy]", "support_async": false, "title": "Export", "view": "/api/view/ExportData/add/?auth_token=[authtoken], "submit": "payload" } }, { "export_bulkload_template": { "method": "POST", "class": "bulkload_template", "href": "/api/data/MSExchangeOnline_powershell_envelope/export_bulkload_template/?hierarchy=[hierarchy]", "support_async": false, "title": "Export Bulk Load Template" } }, { "tag": { "method": "PATCH", "class": "tag", "href": "/api/data/MSExchangeOnline_powershell_envelope/+tag/?hierarchy=[hierarchy]", "support_async": true, "title": "Tag", "view": "/api/view/TagNameForm/add/?auth_token=[authtoken] } }, { "tag_version": { "method": "PATCH", "class": "tag_version", "href": "/api/data/MSExchangeOnline_powershell_envelope/+tag_version/?hierarchy=[hierarchy]", "support_async": true, "title": "Tag Version", "view": "/api/view/TagVersionForm/add/?auth_token=[authtoken] } }, { "configuration_template": { "method": "GET", "class": "config", "href": "/api/data/MSExchangeOnline_powershell_envelope/configuration_template/?hierarchy=[hierarchy]", "support_async": false, "title": "Configuration Template" } }, { "field_display_policy": { "method": "GET", "class": "display_policy", "href": "/api/data/MSExchangeOnline_powershell_envelope/field_display_policy/?hierarchy=[hierarchy]", "support_async": false, "title": "Field Display Policy" } }, { "migration": { "method": "GET", "class": "migration", "href": "/api/data/MSExchangeOnline_powershell_envelope/migration/?hierarchy=[hierarchy]", "support_async": false, "title": "Migration Template" } }, { "list": { "method": "GET", "class": "list", "href": "/api/data/MSExchangeOnline_powershell_envelope/?hierarchy=[hierarchy]", "support_async": false, "title": "List" } }, { "help": { "method": "GET", "class": "help", "href": "/api/data/MSExchangeOnline_powershell_envelope/help?hierarchy=[hierarchy]", "support_async": false, "title": "Help" } }, { "transform": { "method": "GET", "class": "transform", "href": "/api/data/MSExchangeOnline_powershell_envelope/transform/?hierarchy=[hierarchy]", "support_async": false, "title": "Transform Template" } } ] }, "resources": [ { "data": { "name": "default", "envelope": "$OutputEncoding = New-Object -TypeName:System.Text.UTF8Encoding\n[Console]::OutputEncoding = [text.encoding]::UTF8\n\n$envelope_version = 'EXO_v2'\n$hostname = '{{ driver_parameters.get('host', '').replace(\"'\", \"''\") }}'\n$domain_name = @{$true=$hostname; $false='.'}[[bool]'{{ driver_parameters.get('domain_name', '').replace(\"'\", \"''\") }}']\n$local_username = '{{ driver_parameters.get('username', '').replace(\"'\", \"''\") }}'\n$local_password = '{{ driver_parameters.get('password', '').replace(\"'\", \"''\") }}'\n$inet_proxy_username = '{{ driver_parameters.get('proxy_username', '').replace(\"'\", \"''\") }}'\n$inet_proxy_password = '{{ driver_parameters.get('proxy_password', '').replace(\"'\", \"''\") }}'\n$online_admin_domain = '{{ driver_parameters.get('online_admin_domain', '').replace(\"'\", \"''\") }}'\n$online_session_name = $online_admin_domain + '_' + $envelope_version\n\n$local_securestring = ConvertTo-SecureString $local_password -AsPlainText -Force\n$local_credentials = New-Object -TypeName:System.Management.Automation.PSCredential -ArgumentList:($local_username,$local_securestring)\n$sessions = Get-PsSession -Authentication Basic -Credential $local_credentials -ComputerName $domain_name -State Disconnected | Where-Object {$_.Name -eq $online_session_name}\n$cnt = 0;\n$sessionToUse=$null\nforeach ($session in $sessions) {\n try {\n write-output (\"At {0} attempting to connect to session\" -f [DateTime]::now)\n $session | Format-List | Write-Output\n $sessionToUse = Connect-PSSession -Session $session -ErrorAction Stop\n write-output (\"At {0} successfully connected to session\" -f [DateTime]::now)\n $sessionToUse | Format-List | Write-Output\n if ($sessionToUse.Availability -eq 'Busy' -and $sessionToUse.State -eq 'Opened') {\n write-output (\"At {0} the session was busy after connection, trying other sessions\" -f [DateTime]::now)\n continue\n }\n break\n }\n catch {\n Write-Output (\"At {0} session is no longer useable\" -f [DateTime]::now)\n $session | Format-List | Write-Output\n $sessionToUse = $null\n }\n}\n\n$command = {\n{%- block command %}{%- endblock %}\n if ($uc_output -ne $NULL) {$uc_output.type='result'}; return $uc_output\n}\n$maxRetrySeconds = 65\n$startTime = [DateTime]::now\ndo {\n $retryRequired = $false\n if ($sessionToUse -eq $null) {\n Write-Output \"No available sessions starting a new one\"\n try {\n $sessionToUse = New-PsSession -Name $online_session_name -ComputerName $domain_name -Authentication Basic -Credential $local_credentials -ErrorAction Stop\n Write-Output (\"At {0} a new session was created:\" -f [DateTime]::now)\n $sessionToUse | Format-List | Write-Output\n try {\n $null = Invoke-Command -Session $sessionToUse -ScriptBlock $ExScriptBlock -ErrorAction Stop\n $null = Invoke-Command -Session $sessionToUse -ScriptBlock $functionDefinitions -ErrorAction Stop\n $uc_output = Invoke-Command -Session $sessionToUse -ScriptBlock { \n $inet_proxy_username = '{{ driver_parameters.get('proxy_username', '').replace(\"'\", \"''\") }}'\n $inet_proxy_password = '{{ driver_parameters.get('proxy_password', '').replace(\"'\", \"''\") }}'\n $certificate_thumbprint = '{{ driver_parameters.get('certificate_thumbprint', '').replace(\"'\", \"''\") }}'\n $client_id = '{{ driver_parameters.get('client_id', '').replace(\"'\", \"''\") }}'\n $online_admin_domain = '{{ driver_parameters.get('online_admin_domain', '').replace(\"'\", \"''\") }}'\n\n{%- if driver_parameters.get('use_proxy', 'false').lower() in ('true', 't') %}\n $registryPath = \"HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\"\n $proxySettings = (Get-ItemProperty -Path \"$registryPath\\Connections\" -Name DefaultConnectionSettings).DefaultConnectionSettings\n $proxyLen = $proxySettings[12]\n $proxyStart = 16\n $proxyEnd = $proxyStart + $proxyLen - 1\n $proxyString = [System.Text.Encoding]::ASCII.GetString($proxySettings[$proxyStart..$proxyEnd])\n [System.Net.WebRequest]::DefaultWebProxy = New-Object System.Net.WebProxy($proxyString)\n\n {%- if driver_parameters.get('use_proxy_auth', 'false').lower() in ('true', 't') %}\n $inet_proxy_securestring = New-Object -TypeName:System.Security.SecureString\n $inet_proxy_password.ToCharArray() | ForEach-Object { $inet_proxy_securestring.AppendChar($_) }\n $inet_proxy_credentials = New-Object -TypeName:System.Management.Automation.PSCredential -ArgumentList:($inet_proxy_username, $inet_proxy_securestring)\n [System.Net.WebRequest]::DefaultWebProxy.Credentials = $inet_proxy_credentials\n $sessionOptions = New-PSSessionOption -ProxyAccessType IEConfig -ProxyAuthentication Basic -ProxyCredential $inet_proxy_credentials\n {%- else %}\n $sessionOptions = New-PSSessionOption -ProxyAccessType IEConfig\n {%- endif %}\n{%- else %}\n $sessionOptions = New-PSSessionOption\n{%- endif %}\n\n [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12\n $uc_output = @{}\n $uc_output.type = 'result'\n try {\n Connect-ExchangeOnline -CertificateThumbPrint $certificate_thumbprint -AppID $client_id -Organization $online_admin_domain -PSSessionOption $sessionOptions\n $uc_output.success = $true\n }\n catch {\n $defaultErrorText = ''\n $uc_output = Get-GenericPowerShellErrorHandling -ExceptionList $Using:Ex -DefaultErrorText $defaultErrorText -ErrorRecord $Error[0]\n if ($uc_output.result -eq '') {\n $uc_output.result = \"Failed to establish Online Session: <<<$_>>>\"\n }\n else {\n $uc_output.result = 'Failed to establish Online Session:\\n' + $uc_output.result\n }\n $uc_output.retryable = $false\n }\n return $uc_output\n } -ErrorAction Stop\n }\n catch {\n $null = Invoke-Command -NoNewScope -ScriptBlock $functionDefinitions -ErrorAction Stop\n $defaultErrorText = ''\n $uc_output = Get-GenericPowerShellErrorHandling -ExceptionList $Ex -DefaultErrorText $defaultErrorText -ErrorRecord $Error[0]\n $uc_output.type = 'result'\n if ($uc_output.result -eq '') {\n $uc_output.result = \"Failed to invoke PowerShell command in local session: <<<$_>>>\"\n }\n else {\n $uc_output.result = 'Failed to invoke PowerShell command in local session:\\n' + $uc_output.result\n }\n $uc_output.retryable = $false\n $null = Remove-PSSession $sessionToUse\n $sessionToUse = $null\n }\n }\n catch {\n $null = Invoke-Command -NoNewScope -ScriptBlock $functionDefinitions -ErrorAction Stop\n $defaultErrorText = ''\n $uc_output = Get-GenericPowerShellErrorHandling -ExceptionList $Ex -DefaultErrorText $defaultErrorText -ErrorRecord $Error[0]\n $uc_output.type = 'result'\n if ($uc_output.result -eq '') {\n $uc_output.result = \"Failed to establish local PowerShell session: <<<$_>>>\"\n }\n else {\n $uc_output.result = 'Failed to establish local PowerShell session:\\n' + $uc_output.result\n }\n $uc_output.retryable = $false\n $sessionToUse = $null\n }\n }\n else {\n Write-Output (\"At {0} we are re-using this session:\" -f [DateTime]::now)\n $sessionToUse | Format-List | Write-Output\n $uc_output = @{}\n $uc_output.success = $true\n }\n if ($sessionToUse -ne $null -and $uc_output.success -eq $true) {\n try {\n $uc_output = Invoke-Command -Session $sessionToUse -ScriptBlock $command -ErrorAction Stop\n }\n catch {\n $null = Invoke-Command -NoNewScope -ScriptBlock $functionDefinitions -ErrorAction Stop\n $defaultErrorText = ''\n $uc_output = Get-GenericPowerShellErrorHandling -ExceptionList $Ex -DefaultErrorText $defaultErrorText -ErrorRecord $Error[0]\n $uc_output.type = 'result'\n if ($uc_output.result -eq '') {\n $uc_output.result = \"Caught exception executing remote command: <<<$_>>>\"\n }\n else {\n $uc_output.result = 'Caught exception executing remote command:\\n' + $uc_output.result\n }\n }\n $uc_output.type = 'result'\n }\n if ($uc_output.success -eq $false) {\n $duration = ([DateTime]::now - $startTime).TotalSeconds\n Write-Output ('Attempt failed after {0:0} seconds with error:' -f $duration)\n Write-Output $uc_output.result\n if ($uc_output.retryable -eq $true) {\n if (($sleepSeconds = $uc_output.delay) -gt 0) {\n Write-Output \"Sleeping $sleepSeconds\"\n Start-Sleep -Seconds $sleepSeconds\n $retryRequired = ($duration -lt $maxRetrySeconds)\n }\n else {\n $retryRequired = $true\n }\n }\n else {\n $retryRequired = $false\n }\n if ($retryRequired) {\n Write-Output 'Retrying...'\n if ($uc_output.replaceSession -eq $true) {\n Write-Output \"Removing session $($sessionToUse.Name)\"\n Remove-PSSession -Session $sessionToUse\n $sessionToUse = $null\n }\n Clear-Variable uc_output\n }\n }\n else {\n $retryRequired = $false\n }\n} while ($retryRequired)\nif ($sessionToUse) {$null = Disconnect-PSSession $sessionToUse -ErrorAction SilentlyContinue}\nWrite-Output (ConvertTo-Json -Compress:$true -Depth:25 $uc_output)\n", "pkid": "650fe47d84eaf2a1ce6390b9", "hierarchy_friendly_name": "sys (System)", "hierarchy_path": "sys" }, "meta": { "model_type": "data/MSExchangeOnline_powershell_envelope", "summary_attrs": [ { "name": "name", "title": "Name" }, { "name": "hierarchy_friendly_name", "title": "Located At", "allow_filtering": true } ], "tagged_versions": [], "tags": [ "msexchangeonline", "V4UC", "ba_CommonOverlay" ], "title": "default", "business_key": { "hierarchy": true, "unique": [ "name" ] }, "api_version": "21.2", "cached": true, "references": { "device": [ { "href": "", "pkid": "" } ], "owner": [ { "pkid": "" } ], "parent": [ { "pkid": "6t0ggef2c0deab00hb595101", "href": "/api/data/HierarchyNode/6t0ggef2c0deab00hb595101" } ], "foreign_key": [], "self": [ { "href": "/api/data/MSExchangeOnline_powershell_envelope/650fe47d84eaf2a1ce6390b8/", "pkid": "650fe47d84eaf2a1ce6390b8" } ] }, "path": [ "6t0ggef2c0deab00hb595101", "650fe47d84eaf2a1ce6390b8" ], "schema_version": "1.0.0", "actions": [ { "update": { "method": "PUT", "class": "update", "href": "/api/data/MSExchangeOnline_powershell_envelope/650fe47d84eaf2a1ce6390b8/", "support_async": true, "title": "Modify" } }, { "remove": { "method": "DELETE", "class": "delete", "href": "/api/data/MSExchangeOnline_powershell_envelope/650fe47d84eaf2a1ce6390b8/", "support_async": true, "title": "Delete" } }, { "clone": { "method": "GET", "class": "clone", "href": "/api/data/MSExchangeOnline_powershell_envelope/650fe47d84eaf2a1ce6390b8/clone/?schema=&schema_rules=true", "support_async": false, "title": "Clone" } }, { "export": { "method": "GET", "class": "export", "href": "/api/data/MSExchangeOnline_powershell_envelope/650fe47d84eaf2a1ce6390b8/export/", "support_async": false, "title": "Export", "view": "/api/view/ExportData/add/", "submit": "payload" } }, { "tag": { "method": "PATCH", "class": "tag", "href": "/api/data/MSExchangeOnline_powershell_envelope/650fe47d84eaf2a1ce6390b8/+tag/", "support_async": true, "title": "Tag", "view": "/api/view/TagNameForm/add/" } }, { "tag_version": { "method": "PATCH", "class": "tag_version", "href": "/api/data/MSExchangeOnline_powershell_envelope/650fe47d84eaf2a1ce6390b8/+tag_version/", "support_async": true, "title": "Tag Version", "view": "/api/view/TagVersionForm/add/" } }, { "get": { "method": "GET", "class": "get", "href": "/api/data/MSExchangeOnline_powershell_envelope/650fe47d84eaf2a1ce6390b8/", "support_async": false, "title": "Get" } }, { "help": { "method": "GET", "class": "help", "href": "/api/data/MSExchangeOnline_powershell_envelope/650fe47d84eaf2a1ce6390b8/help", "support_async": false, "title": "Help" } } ], "summary": "false" }, "pkid": "650fe47d84eaf2a1ce6390b8" } ] }
(Show the first instance)
{ "data": { "name": "default", "envelope": "$OutputEncoding = New-Object -TypeName:System.Text.UTF8Encoding\n[Console]::OutputEncoding = [text.encoding]::UTF8\n\n$envelope_version = 'EXO_v2'\n$hostname = '{{ driver_parameters.get('host', '').replace(\"'\", \"''\") }}'\n$domain_name = @{$true=$hostname; $false='.'}[[bool]'{{ driver_parameters.get('domain_name', '').replace(\"'\", \"''\") }}']\n$local_username = '{{ driver_parameters.get('username', '').replace(\"'\", \"''\") }}'\n$local_password = '{{ driver_parameters.get('password', '').replace(\"'\", \"''\") }}'\n$inet_proxy_username = '{{ driver_parameters.get('proxy_username', '').replace(\"'\", \"''\") }}'\n$inet_proxy_password = '{{ driver_parameters.get('proxy_password', '').replace(\"'\", \"''\") }}'\n$online_admin_domain = '{{ driver_parameters.get('online_admin_domain', '').replace(\"'\", \"''\") }}'\n$online_session_name = $online_admin_domain + '_' + $envelope_version\n\n$local_securestring = ConvertTo-SecureString $local_password -AsPlainText -Force\n$local_credentials = New-Object -TypeName:System.Management.Automation.PSCredential -ArgumentList:($local_username,$local_securestring)\n$sessions = Get-PsSession -Authentication Basic -Credential $local_credentials -ComputerName $domain_name -State Disconnected | Where-Object {$_.Name -eq $online_session_name}\n$cnt = 0;\n$sessionToUse=$null\nforeach ($session in $sessions) {\n try {\n write-output (\"At {0} attempting to connect to session\" -f [DateTime]::now)\n $session | Format-List | Write-Output\n $sessionToUse = Connect-PSSession -Session $session -ErrorAction Stop\n write-output (\"At {0} successfully connected to session\" -f [DateTime]::now)\n $sessionToUse | Format-List | Write-Output\n if ($sessionToUse.Availability -eq 'Busy' -and $sessionToUse.State -eq 'Opened') {\n write-output (\"At {0} the session was busy after connection, trying other sessions\" -f [DateTime]::now)\n continue\n }\n break\n }\n catch {\n Write-Output (\"At {0} session is no longer useable\" -f [DateTime]::now)\n $session | Format-List | Write-Output\n $sessionToUse = $null\n }\n}\n\n$command = {\n{%- block command %}{%- endblock %}\n if ($uc_output -ne $NULL) {$uc_output.type='result'}; return $uc_output\n}\n$maxRetrySeconds = 65\n$startTime = [DateTime]::now\ndo {\n $retryRequired = $false\n if ($sessionToUse -eq $null) {\n Write-Output \"No available sessions starting a new one\"\n try {\n $sessionToUse = New-PsSession -Name $online_session_name -ComputerName $domain_name -Authentication Basic -Credential $local_credentials -ErrorAction Stop\n Write-Output (\"At {0} a new session was created:\" -f [DateTime]::now)\n $sessionToUse | Format-List | Write-Output\n try {\n $null = Invoke-Command -Session $sessionToUse -ScriptBlock $ExScriptBlock -ErrorAction Stop\n $null = Invoke-Command -Session $sessionToUse -ScriptBlock $functionDefinitions -ErrorAction Stop\n $uc_output = Invoke-Command -Session $sessionToUse -ScriptBlock { \n $inet_proxy_username = '{{ driver_parameters.get('proxy_username', '').replace(\"'\", \"''\") }}'\n $inet_proxy_password = '{{ driver_parameters.get('proxy_password', '').replace(\"'\", \"''\") }}'\n $certificate_thumbprint = '{{ driver_parameters.get('certificate_thumbprint', '').replace(\"'\", \"''\") }}'\n $client_id = '{{ driver_parameters.get('client_id', '').replace(\"'\", \"''\") }}'\n $online_admin_domain = '{{ driver_parameters.get('online_admin_domain', '').replace(\"'\", \"''\") }}'\n\n{%- if driver_parameters.get('use_proxy', 'false').lower() in ('true', 't') %}\n $registryPath = \"HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\"\n $proxySettings = (Get-ItemProperty -Path \"$registryPath\\Connections\" -Name DefaultConnectionSettings).DefaultConnectionSettings\n $proxyLen = $proxySettings[12]\n $proxyStart = 16\n $proxyEnd = $proxyStart + $proxyLen - 1\n $proxyString = [System.Text.Encoding]::ASCII.GetString($proxySettings[$proxyStart..$proxyEnd])\n [System.Net.WebRequest]::DefaultWebProxy = New-Object System.Net.WebProxy($proxyString)\n\n {%- if driver_parameters.get('use_proxy_auth', 'false').lower() in ('true', 't') %}\n $inet_proxy_securestring = New-Object -TypeName:System.Security.SecureString\n $inet_proxy_password.ToCharArray() | ForEach-Object { $inet_proxy_securestring.AppendChar($_) }\n $inet_proxy_credentials = New-Object -TypeName:System.Management.Automation.PSCredential -ArgumentList:($inet_proxy_username, $inet_proxy_securestring)\n [System.Net.WebRequest]::DefaultWebProxy.Credentials = $inet_proxy_credentials\n $sessionOptions = New-PSSessionOption -ProxyAccessType IEConfig -ProxyAuthentication Basic -ProxyCredential $inet_proxy_credentials\n {%- else %}\n $sessionOptions = New-PSSessionOption -ProxyAccessType IEConfig\n {%- endif %}\n{%- else %}\n $sessionOptions = New-PSSessionOption\n{%- endif %}\n\n [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12\n $uc_output = @{}\n $uc_output.type = 'result'\n try {\n Connect-ExchangeOnline -CertificateThumbPrint $certificate_thumbprint -AppID $client_id -Organization $online_admin_domain -PSSessionOption $sessionOptions\n $uc_output.success = $true\n }\n catch {\n $defaultErrorText = ''\n $uc_output = Get-GenericPowerShellErrorHandling -ExceptionList $Using:Ex -DefaultErrorText $defaultErrorText -ErrorRecord $Error[0]\n if ($uc_output.result -eq '') {\n $uc_output.result = \"Failed to establish Online Session: <<<$_>>>\"\n }\n else {\n $uc_output.result = 'Failed to establish Online Session:\\n' + $uc_output.result\n }\n $uc_output.retryable = $false\n }\n return $uc_output\n } -ErrorAction Stop\n }\n catch {\n $null = Invoke-Command -NoNewScope -ScriptBlock $functionDefinitions -ErrorAction Stop\n $defaultErrorText = ''\n $uc_output = Get-GenericPowerShellErrorHandling -ExceptionList $Ex -DefaultErrorText $defaultErrorText -ErrorRecord $Error[0]\n $uc_output.type = 'result'\n if ($uc_output.result -eq '') {\n $uc_output.result = \"Failed to invoke PowerShell command in local session: <<<$_>>>\"\n }\n else {\n $uc_output.result = 'Failed to invoke PowerShell command in local session:\\n' + $uc_output.result\n }\n $uc_output.retryable = $false\n $null = Remove-PSSession $sessionToUse\n $sessionToUse = $null\n }\n }\n catch {\n $null = Invoke-Command -NoNewScope -ScriptBlock $functionDefinitions -ErrorAction Stop\n $defaultErrorText = ''\n $uc_output = Get-GenericPowerShellErrorHandling -ExceptionList $Ex -DefaultErrorText $defaultErrorText -ErrorRecord $Error[0]\n $uc_output.type = 'result'\n if ($uc_output.result -eq '') {\n $uc_output.result = \"Failed to establish local PowerShell session: <<<$_>>>\"\n }\n else {\n $uc_output.result = 'Failed to establish local PowerShell session:\\n' + $uc_output.result\n }\n $uc_output.retryable = $false\n $sessionToUse = $null\n }\n }\n else {\n Write-Output (\"At {0} we are re-using this session:\" -f [DateTime]::now)\n $sessionToUse | Format-List | Write-Output\n $uc_output = @{}\n $uc_output.success = $true\n }\n if ($sessionToUse -ne $null -and $uc_output.success -eq $true) {\n try {\n $uc_output = Invoke-Command -Session $sessionToUse -ScriptBlock $command -ErrorAction Stop\n }\n catch {\n $null = Invoke-Command -NoNewScope -ScriptBlock $functionDefinitions -ErrorAction Stop\n $defaultErrorText = ''\n $uc_output = Get-GenericPowerShellErrorHandling -ExceptionList $Ex -DefaultErrorText $defaultErrorText -ErrorRecord $Error[0]\n $uc_output.type = 'result'\n if ($uc_output.result -eq '') {\n $uc_output.result = \"Caught exception executing remote command: <<<$_>>>\"\n }\n else {\n $uc_output.result = 'Caught exception executing remote command:\\n' + $uc_output.result\n }\n }\n $uc_output.type = 'result'\n }\n if ($uc_output.success -eq $false) {\n $duration = ([DateTime]::now - $startTime).TotalSeconds\n Write-Output ('Attempt failed after {0:0} seconds with error:' -f $duration)\n Write-Output $uc_output.result\n if ($uc_output.retryable -eq $true) {\n if (($sleepSeconds = $uc_output.delay) -gt 0) {\n Write-Output \"Sleeping $sleepSeconds\"\n Start-Sleep -Seconds $sleepSeconds\n $retryRequired = ($duration -lt $maxRetrySeconds)\n }\n else {\n $retryRequired = $true\n }\n }\n else {\n $retryRequired = $false\n }\n if ($retryRequired) {\n Write-Output 'Retrying...'\n if ($uc_output.replaceSession -eq $true) {\n Write-Output \"Removing session $($sessionToUse.Name)\"\n Remove-PSSession -Session $sessionToUse\n $sessionToUse = $null\n }\n Clear-Variable uc_output\n }\n }\n else {\n $retryRequired = $false\n }\n} while ($retryRequired)\nif ($sessionToUse) {$null = Disconnect-PSSession $sessionToUse -ErrorAction SilentlyContinue}\nWrite-Output (ConvertTo-Json -Compress:$true -Depth:25 $uc_output)\n", "pkid": "650fe47d84eaf2a1ce6390b9" }, "meta": { "model_type": "data/MSExchangeOnline_powershell_envelope", "summary_attrs": [ { "name": "name", "title": "Name" }, { "name": "hierarchy_friendly_name", "title": "Located At", "allow_filtering": true } ], "tagged_versions": [], "tags": [ "msexchangeonline", "V4UC", "ba_CommonOverlay" ], "title": "default", "business_key": { "hierarchy": true, "unique": [ "name" ] }, "api_version": "21.2", "cached": false, "references": { "device": [ { "href": "", "pkid": "" } ], "owner": [ { "pkid": "" } ], "parent": [ { "href": "/api/data/HierarchyNode/6t0ggef2c0deab00hb595101", "pkid": "6t0ggef2c0deab00hb595101" } ], "foreign_key": [], "children": [], "self": [ { "href": "/api/data/MSExchangeOnline_powershell_envelope/650fe47d84eaf2a1ce6390b8/", "pkid": "650fe47d84eaf2a1ce6390b8" } ] }, "path": [ "6t0ggef2c0deab00hb595101", "650fe47d84eaf2a1ce6390b8" ], "schema_version": "1.0.0", "actions": [ { "update": { "method": "PUT", "class": "update", "href": "/api/data/MSExchangeOnline_powershell_envelope/650fe47d84eaf2a1ce6390b8/?hierarchy=[hierarchy]", "support_async": true, "title": "Modify" } }, { "remove": { "method": "DELETE", "class": "delete", "href": "/api/data/MSExchangeOnline_powershell_envelope/650fe47d84eaf2a1ce6390b8/?hierarchy=[hierarchy]", "support_async": true, "title": "Delete" } }, { "clone": { "method": "GET", "class": "clone", "href": "/api/data/MSExchangeOnline_powershell_envelope/650fe47d84eaf2a1ce6390b8/clone/?hierarchy=[hierarchy]&schema=&schema_rules=true", "support_async": false, "title": "Clone" } }, { "export": { "method": "GET", "class": "export", "href": "/api/data/MSExchangeOnline_powershell_envelope/650fe47d84eaf2a1ce6390b8/export/?hierarchy=[hierarchy]", "support_async": false, "title": "Export", "view": "/api/view/ExportData/add/?auth_token=[authtoken], "submit": "payload" } }, { "tag": { "method": "PATCH", "class": "tag", "href": "/api/data/MSExchangeOnline_powershell_envelope/650fe47d84eaf2a1ce6390b8/+tag/?hierarchy=[hierarchy]", "support_async": true, "title": "Tag", "view": "/api/view/TagNameForm/add/?auth_token=[authtoken] } }, { "tag_version": { "method": "PATCH", "class": "tag_version", "href": "/api/data/MSExchangeOnline_powershell_envelope/650fe47d84eaf2a1ce6390b8/+tag_version/?hierarchy=[hierarchy]", "support_async": true, "title": "Tag Version", "view": "/api/view/TagVersionForm/add/?auth_token=[authtoken] } }, { "get": { "method": "GET", "class": "get", "href": "/api/data/MSExchangeOnline_powershell_envelope/650fe47d84eaf2a1ce6390b8/?hierarchy=[hierarchy]", "support_async": false, "title": "Get" } }, { "help": { "method": "GET", "class": "help", "href": "/api/data/MSExchangeOnline_powershell_envelope/650fe47d84eaf2a1ce6390b8/help?hierarchy=[hierarchy]", "support_async": false, "title": "Help" } } ] }, "pkid": "650fe47d84eaf2a1ce6390b8" }
Task | Call | URL | Parameters | Response |
---|---|---|---|---|
Get the on-line Help for data/MSExchangeOnline_powershell_envelope. | GET | /api/data/MSExchangeOnline_powershell_envelope/help | hierarchy=[hierarchy] | On-line help of Model ref.: data/MSExchangeOnline_powershell_envelope as HTML |
Task | Call | URL | Parameters | Response |
---|---|---|---|---|
Transform Template | GET | /api/data/MSExchangeOnline_powershell_envelope/transform/ |
|
Task | Call | URL | Parameters | Payload |
---|---|---|---|---|
Modify | PUT | /api/data/MSExchangeOnline_powershell_envelope/[pkid] | hierarchy=[hierarchy] | (For payload specification) |
For Bulk modification, refer to the Bulk Modify section.
Task | Call | URL | Parameters | Response |
---|---|---|---|---|
Delete | DELETE | /api/data/MSExchangeOnline_powershell_envelope/[pkid] | hierarchy=[hierarchy] |
Task | Call | URL | Parameters | Response |
---|---|---|---|---|
Clone instance with [pkid]. The schema rules are applied. | GET | /api/data/MSExchangeOnline_powershell_envelope/[pkid]/clone/?schema=&schema_rules=true |
|
A JSON payload with:
|
GET http://[host-proxy]/api/data/MSExchangeOnline_powershell_envelope/?hierarchy=[hierarchy]&format=json
Task | Call | URL | Parameters | Response |
---|---|---|---|---|
Get a selected [export_format] of the schema and a single instance with [pkid] of data/MSExchangeOnline_powershell_envelope; optionally with tag_version at [version] and Configuration Template as [configtemplate]. | GET | /api/data/MSExchangeOnline_powershell_envelope/[pkid]/export |
|
The response is an attachment. Refer to the list below. |
For export_format=raw_xlsx, the response is a "raw" MS Excel spreadsheet with columns corresponding to the JSON format export and a response format:
Content-Disposition: attachment; filename=<resource_type>_<resource_name>_exportedsheet_CCYY-MM-DD_HH-MM-SS.xlsx Content-Language:en Content-Type:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
For export_format=xlsx, the response is a MS Excel spreadsheet, formatted to show all columns and a response format:
Content-Disposition: attachment; filename=<resource_type>_<resource_name>_exportedsheet_formatted_CCYY-MM-DD_HH-MM-SS.xlsx Content-Language:en Content-Type:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
For export_format=json, the response is a time stamped zip file of data in JSON and a response format:
Content-Disposition: attachment; filename=export_2013-05-17_14:20:19.186444.json.zip Content-Language:en Content-Type:application/x-zip
The XLSX format can be used to bulk load instances of data/MSExchangeOnline_powershell_envelope and the JSON format can be used to import instances of data/MSExchangeOnline_powershell_envelope.
For Bulk Export, refer to the Bulk Export section.
Task | Call | URL | Parameters | Payload |
---|---|---|---|---|
Tag | PATCH | /api/data/MSExchangeOnline_powershell_envelope/[pkid]/+tag | hierarchy=[hierarchy] | If payload required: |
Task | Call | URL | Parameters | Response |
---|---|---|---|---|
Get | GET | /api/data/MSExchangeOnline_powershell_envelope/[pkid] | hierarchy=[hierarchy] | The data/MSExchangeOnline_powershell_envelope instance with [pkid]. |
Task | Call | URL | Parameters | Response |
---|---|---|---|---|
Help | GET | /api/data/MSExchangeOnline_powershell_envelope/[pkid]/help | hierarchy=[hierarchy] | The on-line Help for data/MSExchangeOnline_powershell_envelope. |