{"id":2156,"date":"2025-07-23T08:46:36","date_gmt":"2025-07-23T07:46:36","guid":{"rendered":"https:\/\/kasperjohansen.net\/?p=2156"},"modified":"2025-07-23T12:49:30","modified_gmt":"2025-07-23T11:49:30","slug":"how-to-automate-global-secure-access-private-access-applications","status":"publish","type":"post","link":"https:\/\/kasperjohansen.net\/index.php\/2025\/07\/23\/how-to-automate-global-secure-access-private-access-applications\/","title":{"rendered":"How to automate Global Secure Access Private Access applications"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Automation has been a large part of my career as a consultant. Small scripts to solve mundane tasks during user logon or Windows startup is a way of automating tasks, another way is to install or configure Windows and applications in Windows. Speaking of applications, make sure to read my article about how to <a href=\"https:\/\/kasperjohansen.net\/index.php\/2025\/02\/18\/deploy-global-secure-access-client-with-microsoft-intune-and-psadt\/\">deploy and configure the Global Secure Access Client using Microsoft Intune and Powershell AppDeploy Toolkit<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">As I have been working with Global Secure Access for quite some time, I wanted to explore the possibilities of automating certain elements of Global Secure Access, specifically the application creation part. Creating an application in Global Secure Access involves a certain level of clicking around in the Entra admin center portal and if you are creating a lot of applications it may become a bit tedious using the manual approach. If you are just starting with Global Secure Access make sure to read my article about how to <a href=\"https:\/\/kasperjohansen.net\/index.php\/2025\/01\/29\/get-started-with-global-secure-access-private-access\/\">get started with Global Secure Access<\/a>, this will among other things, cover how to manually create an application in the Entra admin center.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I was recently on an assignment which brought me out of my comfort zone, a good thing to do from time to time as it may provide new ways of looking at certain tasks or maybe even learn new stuff, for me it was the latter. In this case the assignment was to provide information about how to create, update and delete a Global Secure Access Private Access application using the Microsoft Graph API.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Before this assignment, I had never worked with the Microsoft Graph API or any other API for that matter, so this was completely unknown territory for me. I was not able to find much information about how to approach the task of creating, updating and deleting Global Secure Access Private Access applications, using Microsoft Graph API. However, using the <a href=\"https:\/\/learn.microsoft.com\/en-us\/graph\/api\/resources\/applications-api-overview?view=graph-rest-beta\">documentation provided by Microsoft on the Graph API<\/a>, I was able to at least get a sense of what to do and how to approach it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In this article I have gathered and documented what I have learned about Microsoft Graph API and how to use the API with Global Secure Access Private Access. I&#8217;ll provide Powershell scripts to create, update and delete a Private Access application.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Before going any further, I want to mention that Powershell modules to manage Global Secure Access Private Access do exist and you can find more information about the module and commands on the <a href=\"https:\/\/microsoft.github.io\/GlobalSecureAccess\/Entra%20Private%20Access\/powershell\/\">Global Secure Access  &#8211; Community Resources Hub<\/a>.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_86 counter-hierarchy ez-toc-counter ez-toc-transparent ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/kasperjohansen.net\/index.php\/2025\/07\/23\/how-to-automate-global-secure-access-private-access-applications\/#Microsoft_Graph_API_communication\" >Microsoft Graph API communication<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/kasperjohansen.net\/index.php\/2025\/07\/23\/how-to-automate-global-secure-access-private-access-applications\/#Prerequisites\" >Prerequisites<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/kasperjohansen.net\/index.php\/2025\/07\/23\/how-to-automate-global-secure-access-private-access-applications\/#Create_app_registration\" >Create app registration<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/kasperjohansen.net\/index.php\/2025\/07\/23\/how-to-automate-global-secure-access-private-access-applications\/#Get_API_access_token\" >Get API access token<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/kasperjohansen.net\/index.php\/2025\/07\/23\/how-to-automate-global-secure-access-private-access-applications\/#Create_HTTP_headers\" >Create HTTP headers<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/kasperjohansen.net\/index.php\/2025\/07\/23\/how-to-automate-global-secure-access-private-access-applications\/#Create_a_Private_Access_application\" >Create a Private Access application<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/kasperjohansen.net\/index.php\/2025\/07\/23\/how-to-automate-global-secure-access-private-access-applications\/#Create_an_application_instance\" >Create an application instance<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/kasperjohansen.net\/index.php\/2025\/07\/23\/how-to-automate-global-secure-access-private-access-applications\/#Create_application_segment\" >Create application segment<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/kasperjohansen.net\/index.php\/2025\/07\/23\/how-to-automate-global-secure-access-private-access-applications\/#Assign_a_connector_group\" >Assign a connector group<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/kasperjohansen.net\/index.php\/2025\/07\/23\/how-to-automate-global-secure-access-private-access-applications\/#Complete_script_to_create_an_application_using_Microsoft_Graph_API\" >Complete script to create an application using Microsoft Graph API<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/kasperjohansen.net\/index.php\/2025\/07\/23\/how-to-automate-global-secure-access-private-access-applications\/#Update_Private_Access_application\" >Update Private Access application<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/kasperjohansen.net\/index.php\/2025\/07\/23\/how-to-automate-global-secure-access-private-access-applications\/#Update_application_instance_name\" >Update application instance name<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/kasperjohansen.net\/index.php\/2025\/07\/23\/how-to-automate-global-secure-access-private-access-applications\/#Update_application_segment\" >Update application segment<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-14\" href=\"https:\/\/kasperjohansen.net\/index.php\/2025\/07\/23\/how-to-automate-global-secure-access-private-access-applications\/#Delete_Private_Access_application\" >Delete Private Access application<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-15\" href=\"https:\/\/kasperjohansen.net\/index.php\/2025\/07\/23\/how-to-automate-global-secure-access-private-access-applications\/#Delete_application_instance\" >Delete application instance<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-16\" href=\"https:\/\/kasperjohansen.net\/index.php\/2025\/07\/23\/how-to-automate-global-secure-access-private-access-applications\/#Delete_application_segment\" >Delete application segment<\/a><\/li><\/ul><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Microsoft_Graph_API_communication\"><\/span>Microsoft Graph API communication<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Prerequisites\"><\/span>Prerequisites<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Global Secure Access must be initialized and configured, and you must have at lease one active connector group before going any further.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Create_app_registration\"><\/span>Create app registration<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">To securely communicate with your Microsoft Entra tenant using the Microsoft Graph API, you can use an app registration with a limited set of permissions.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To create an app registration go to app registrations in the Entra admin center:<\/p>\n\n\n\n<figure class=\"wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-1 is-layout-flex wp-block-gallery-is-layout-flex\">\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-01.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"412\" data-id=\"2197\" src=\"https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-01-1024x412.jpg\" alt=\"\" class=\"wp-image-2197\" srcset=\"https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-01-1024x412.jpg 1024w, https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-01-300x121.jpg 300w, https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-01-768x309.jpg 768w, https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-01.jpg 1441w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-02.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"806\" data-id=\"2198\" src=\"https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-02-1024x806.jpg\" alt=\"\" class=\"wp-image-2198\" srcset=\"https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-02-1024x806.jpg 1024w, https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-02-300x236.jpg 300w, https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-02-768x605.jpg 768w, https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-02.jpg 1158w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n<\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Click new registration and provide a name and then click register<\/p>\n\n\n\n<figure class=\"wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-2 is-layout-flex wp-block-gallery-is-layout-flex\">\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-03.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"352\" data-id=\"2201\" src=\"https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-03-1024x352.jpg\" alt=\"\" class=\"wp-image-2201\" srcset=\"https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-03-1024x352.jpg 1024w, https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-03-300x103.jpg 300w, https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-03-768x264.jpg 768w, https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-03-1536x528.jpg 1536w, https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-03.jpg 1612w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-04.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"543\" data-id=\"2200\" src=\"https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-04-1024x543.jpg\" alt=\"\" class=\"wp-image-2200\" srcset=\"https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-04-1024x543.jpg 1024w, https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-04-300x159.jpg 300w, https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-04-768x407.jpg 768w, https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-04.jpg 1324w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n<\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Make a note of the application id, we are going to need that later. Click certificates and secrets and click new client secret<\/p>\n\n\n\n<figure class=\"wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-3 is-layout-flex wp-block-gallery-is-layout-flex\">\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-05.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"567\" height=\"923\" data-id=\"2203\" src=\"https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-05.jpg\" alt=\"\" class=\"wp-image-2203\" srcset=\"https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-05.jpg 567w, https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-05-184x300.jpg 184w\" sizes=\"auto, (max-width: 567px) 100vw, 567px\" \/><\/a><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-06.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"227\" data-id=\"2204\" src=\"https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-06-1024x227.jpg\" alt=\"\" class=\"wp-image-2204\" srcset=\"https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-06-1024x227.jpg 1024w, https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-06-300x66.jpg 300w, https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-06-768x170.jpg 768w, https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-06.jpg 1056w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n<\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Select when the client secret should expire. Make a note of the client secret now, it will only be visible this one time.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Make sure to store your client secret in a safe location! <\/strong><\/p>\n\n\n\n<figure class=\"wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-4 is-layout-flex wp-block-gallery-is-layout-flex\">\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-07.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"437\" data-id=\"2207\" src=\"https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-07-1024x437.jpg\" alt=\"\" class=\"wp-image-2207\" srcset=\"https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-07-1024x437.jpg 1024w, https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-07-300x128.jpg 300w, https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-07-768x328.jpg 768w, https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-07-1536x655.jpg 1536w, https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-07.jpg 1629w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-08.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"824\" height=\"799\" data-id=\"2208\" src=\"https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-08.jpg\" alt=\"\" class=\"wp-image-2208\" srcset=\"https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-08.jpg 824w, https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-08-300x291.jpg 300w, https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-08-768x745.jpg 768w\" sizes=\"auto, (max-width: 824px) 100vw, 824px\" \/><\/a><\/figure>\n<\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The last thing we need to do is to add permissions to the app registration. Click API permissions, Add permissions and select Microsoft Graph<\/p>\n\n\n\n<figure class=\"wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-5 is-layout-flex wp-block-gallery-is-layout-flex\">\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-09.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"856\" height=\"420\" data-id=\"2209\" src=\"https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-09.jpg\" alt=\"\" class=\"wp-image-2209\" srcset=\"https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-09.jpg 856w, https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-09-300x147.jpg 300w, https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-09-768x377.jpg 768w\" sizes=\"auto, (max-width: 856px) 100vw, 856px\" \/><\/a><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-10-2.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"851\" height=\"927\" data-id=\"2214\" src=\"https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-10-2.jpg\" alt=\"\" class=\"wp-image-2214\" srcset=\"https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-10-2.jpg 851w, https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-10-2-275x300.jpg 275w, https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-10-2-768x837.jpg 768w\" sizes=\"auto, (max-width: 851px) 100vw, 851px\" \/><\/a><\/figure>\n<\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Click Application permissions. In the select permissions search box type Application.ReadWrite.All and select it in the box below the search box.<\/p>\n\n\n\n<figure class=\"wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-6 is-layout-flex wp-block-gallery-is-layout-flex\">\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-11.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"847\" height=\"913\" data-id=\"2211\" src=\"https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-11.jpg\" alt=\"\" class=\"wp-image-2211\" srcset=\"https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-11.jpg 847w, https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-11-278x300.jpg 278w, https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-11-768x828.jpg 768w\" sizes=\"auto, (max-width: 847px) 100vw, 847px\" \/><\/a><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-12.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"301\" data-id=\"2212\" src=\"https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-12-1024x301.jpg\" alt=\"\" class=\"wp-image-2212\" srcset=\"https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-12-1024x301.jpg 1024w, https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-12-300x88.jpg 300w, https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-12-768x226.jpg 768w, https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-12.jpg 1078w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n<\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Return to the search box and type Directory.ReadWrite.All and select it in the box below the search box and click add permissions. The configured permissions should look like the second image. Make sure to remove the User.Read permissions via the 3 small dots. Next click Grant admin consent.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>The Grant admin consent requires privileged permissions in the tenant, like the Privileged ROle Administrator or Global Administrator.<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-13.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"258\" src=\"https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-13-1024x258.jpg\" alt=\"\" class=\"wp-image-2217\" srcset=\"https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-13-1024x258.jpg 1024w, https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-13-300x76.jpg 300w, https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-13-768x194.jpg 768w, https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-AppReg-13.jpg 1067w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The end result should look like this.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Get_API_access_token\"><\/span>Get API access token<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Using the app registration application (client) ID and our newly created client secret, we can now create a $body variable, this variable will become handy in the next step.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$clientID = \"\"\n$ClientSecret = \"\"\n$body = @{\n    client_id = $clientID\n    client_secret = $ClientSecret\n    scope = \"https:\/\/graph.microsoft.com\/.default\"\n    grant_type = \"client_credentials\"\n}\n$tenantID = \"\"\n$TokenEndpoint = \"https:\/\/login.microsoft.com\/$tenantId\/oauth2\/v2.0\/token\"\n$tokenResponse = Invoke-RestMethod -Uri $TokenEndpoint -Method POST -Body $body -ContentType \"application\/x-www-form-urlencoded\"\n$AccessToken = $tokenResponse.access_token<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The $TenantID variable must contain the Tenant ID of your Entra ID. You can find the tenant ID here:<\/p>\n\n\n\n<figure class=\"wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-7 is-layout-flex wp-block-gallery-is-layout-flex\">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"375\" data-id=\"2171\" src=\"https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-01-1024x375.jpg\" alt=\"\" class=\"wp-image-2171\" srcset=\"https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-01-1024x375.jpg 1024w, https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-01-300x110.jpg 300w, https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-01-768x281.jpg 768w, https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-01.jpg 1449w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n<\/figure>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Create_HTTP_headers\"><\/span>Create HTTP headers<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">With the $body variable in place, we&#8217;ll now create a $Headers variable containing an access token to authorize the communication with Entra ID using the app registration and the content-type which in this case is application\/json.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$Headers = @{\n    Authorization = \"Bearer $AccessToken\"\n    \"Content-Type\" = \"application\/json\"\n}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">With this, we are now ready to create an application.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Create_a_Private_Access_application\"><\/span>Create a Private Access application<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Now that we have the prequisites sorted, we can now create an application called &#8220;New File Server&#8221;. Applications in Global Secure Access is located here:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-02.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"460\" src=\"https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-02-1024x460.jpg\" alt=\"\" class=\"wp-image-2175\" srcset=\"https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-02-1024x460.jpg 1024w, https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-02-300x135.jpg 300w, https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-02-768x345.jpg 768w, https:\/\/kasperjohansen.net\/wp-content\/uploads\/2025\/07\/EntraID-02.jpg 1377w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Create_an_application_instance\"><\/span>Create an application instance<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Again, we&#8217;ll start with creating a $body variable:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$ApplicationName = \"New File Server\"\n$Body = @{\n    displayName = $ApplicationName\n} | ConvertTo-Json -Depth 99 -Compress<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The $ApplicationName variable must contain the name of the application, e.g. &#8220;New File Server&#8221;.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Next step is to create an array of parameters in the $params variable. This array contains the Method, Uri, Headers and Body.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Method is &#8220;Post&#8221; which means create. The Uri, in this case, refers to the Enterprise application template to be used to create the new application. Headers refers to the $Headers variable created earlier, and Body refers to the $Body variable created above and in this case the Body is converted to JSON using the ConvertTo-Json command.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$params = @{\n    Method  = 'POST'\n    Uri = 'https:\/\/graph.microsoft.com\/beta\/applicationTemplates\/8adf8e6e-67b2-4cf2-a259-e3dc5476c621\/instantiate'\n    Headers = $Headers\n    Body = $Body\n}\n$newApp = Invoke-RestMethod @params<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Using the command Invoke-RestMethod @params will communicate with the Microsoft Graph API and create the application. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Here the Invoke-RestMethod @params is called via a variable, as we&#8217;ll need the object id of our newly created application.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Next step is to configure the application to be accessible via Global Secure Access Private Access.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$newAppId = $newApp.application.objectId\n$body = @{\n    onPremisesPublishing = @{\n        applicationType = \"nonwebapp\"\n        isAccessibleViaZTNAClient = \"true\"\n    }\n} | ConvertTo-Json -Depth 99 -Compress\n\n$params = @{\n    Method = 'PATCH'\n    Uri = \"https:\/\/graph.microsoft.com\/beta\/applications\/$newAppId\"\n    Headers = $Headers\n    Body = $body\n}\nInvoke-RestMethod @params<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The $newAppid variable is used to get the object id of the new application created. The $Body contents will enable the new application to be accessible via Private Access. In the $params variable the Method is &#8220;Patch&#8221; this is because we are modifying or changing an existing application. The Uri points to the URL of the new application. As before, the Headers contain the $Headers and Body contain the $Body<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Create_application_segment\"><\/span>Create application segment<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Now we are ready to configure the application segment which enables access to the on-prem resource\/resources. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Again, we&#8217;ll configure the $Body must contain the destinationHost, protocol, ports and destinationType.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Here I am configuring access to the FQDN &#8220;srvfile.domain.com&#8221; on port 445 tcp.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$body = @{\n        destinationHost = \"srvfile.domain.com\"\n        protocol = \"tcp\"\n        ports = @('445-445')\n        destinationType = \"fqdn\"\n} | ConvertTo-Json -Depth 99 -Compress\n\n$params = @{\n        Method = 'POST'\n        Uri = \"https:\/\/graph.microsoft.com\/beta\/applications\/$newAppId\/onPremisesPublishing\/segmentsConfiguration\/microsoft.graph.ipSegmentConfiguration\/applicationSegments\"\n        Headers = $Headers\n        Body = $body\n}\nInvoke-RestMethod @params<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The Method is &#8220;Post&#8221; as we are creating a new application segment the URI contain the URL to the applicationSegments in the application object id specified by the $newAppId earlier.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Assign_a_connector_group\"><\/span>Assign a connector group<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">The assignment of a connector group is only needed, if you have more than one connector group. If you only have one connector group, this will be the default connector group selected when creating a new application.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$ConnectorGroupName = \"Default\"\n$ConnectorGroupId = (Invoke-RestMethod -Method Get -Uri \"https:\/\/graph.microsoft.com\/beta\/onPremisesPublishingProfiles\/applicationproxy\/connectorGroups?`$Filter=name eq '$ConnectorGroupName'\" -Headers $Headers).Value.Id\n\n$Body = @{\n    \"@odata.id\" = \"https:\/\/graph.microsoft.com\/beta\/onPremisesPublishingProfiles\/applicationproxy\/connectorGroups\/$ConnectorGroupId\"    \n} | ConvertTo-Json -Depth 99 -Compress\n\n$params = @{\n        Method  = 'PUT'\n        Uri     = \"https:\/\/graph.microsoft.com\/beta\/applications\/$newAppId\/connectorGroup\/`$ref\"\n        Headers = $Headers\n        Body    = $Body\n}\nInvoke-RestMethod @params<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The $ConnectorgroupName variable must contain the name of the Connector Group, in this case it&#8217;s &#8220;Default&#8221;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Again, a $Body is created with the Connector Group Id and converted to JSON. A $params variable is created with the Method &#8220;Put&#8221; this is because we want to replace the current Connector Group name. The Uri must have this $ref at the end, I have not been able to find out why.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Complete_script_to_create_an_application_using_Microsoft_Graph_API\"><\/span>Complete script to create an application using Microsoft Graph API<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">You can find a complete script to create a new application using Microsoft Graph API in my Gihub repo here:<br><a href=\"https:\/\/github.com\/kaspersmjohansen\/Global-Secure-Access-Scripts\/blob\/main\/Global%20Secure%20Access%20Graph%20API\/Create%20New%20Application.ps1\">Global-Secure-Access-Scripts\/Global Secure Access Graph API\/Create New Application.ps1 at main \u00b7 kaspersmjohansen\/Global-Secure-Access-Scripts<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Update_Private_Access_application\"><\/span>Update Private Access application<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Using Microsoft Graph API we can of course also modify\/update an existing application and existing application segment. Below are examples of how to rename an existing application and how to modify an existing application segment.<br><br>By now I hope you have a good understanding of how to work with the Microsoft Graph API as the next sections will not be as detailed as the section about creating an application.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Update_application_instance_name\"><\/span>Update application instance name<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Here is how to rename an existing application.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">ApplicationName = \"New File Server\"\n$NewApplicationName = \"Brand new File Server\"\n\n$params = @{\n    Method = 'Get'\n    Uri = \"https:\/\/graph.microsoft.com\/beta\/applications?`$Filter=displayname eq '$ApplicationName'\"\n    Headers = $Headers\n}\n$App = Invoke-RestMethod @params\n$AppId = $App.value.id\n\n$Body = @{\n    displayName = $NewApplicationName\n} | ConvertTo-Json -Depth 99 -Compress\n\n$params = @{\n    Method = 'PATCH'\n    Uri = \"https:\/\/graph.microsoft.com\/beta\/applications\/$AppId\"\n    Headers = $Headers\n    Body = $body\n}\nInvoke-RestMethod @params<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">We are getting a bit more advanced here. The $ApplicationName variable must contain the name of the application you want to rename. The $NewApplicationName must contain the new application name.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Next, with a few additional lines of code, we will have a script to rename an existing application. <\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Update_application_segment\"><\/span>Update application segment<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Here is how to update\/modify an existing application segment with an additional port.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$ApplicationName = \"New File Server\"\n$params = @{\n    Method = 'Get'\n    Uri = \"https:\/\/graph.microsoft.com\/beta\/applications\/?`$Filter=displayname eq '$ApplicationName'\"\n    Headers = $Headers\n}\n$App = Invoke-RestMethod @params\n$AppId = $App.value.id\n\n$ApplicationSegmentName = \"srvfile.domain.com\"\n$params = @{\n    Method = 'Get'\n    Uri = \"https:\/\/graph.microsoft.com\/beta\/applications\/$AppId\/onPremisesPublishing\/segmentsConfiguration\/microsoft.graph.IpSegmentConfiguration\/ApplicationSegments?`$Filter=destinationHost eq '$ApplicationSegmentName'\"\n    Headers = $Headers\n}\n$AppSegment = Invoke-RestMethod @params\n$AppSegmentId = $AppSegment.value.id\n\n$body = @{\n        ports = @('445-445','3389-3389')\n} | ConvertTo-Json -Depth 99 -Compress\n\n$params = @{\n    Method = 'Patch'\n    Uri = \"https:\/\/graph.microsoft.com\/beta\/applications\/$AppId\/onPremisesPublishing\/segmentsConfiguration\/microsoft.graph.IpSegmentConfiguration\/ApplicationSegments\/$AppSegmentId\"\n    Headers = $Headers\n    Body = $body\n}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Staying in the more advanced path here. The $ApplicationName must contain the name of the application where you want to update\/modify an application segment. The $ApplicationSegmentName must contain the name of the application segment.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The $Body must contain the property you want to change, in this case it is the &#8220;ports&#8221; property where we are adding port 3389, so that the application segment contains both port 445 and 3389.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Be aware that the body may only contain one property, which means you can&#8217;t have both ports and protocols in the body, you must create an additional body for the protocol value.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Delete_Private_Access_application\"><\/span>Delete Private Access application<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Using Microsoft Graph API we can also delete an existing application and application segment. Below are examples of how to delete an existing application and delete an existing application segment.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Delete_application_instance\"><\/span>Delete application instance<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Here is how to delete an existing application.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$ApplicationName = \"New File Server\"\n$params = @{\n    Method = 'Get'\n    Uri = \"https:\/\/graph.microsoft.com\/beta\/applications\/?`$Filter=displayname eq '$ApplicationName'\"\n    Headers = $Headers\n}\n$App = Invoke-RestMethod @params\n$AppId = $App.value.id\n\n$params = @{\n    Method = 'Delete'\n    Uri = \"https:\/\/graph.microsoft.com\/beta\/applications\/$AppId\"\n    Headers = $Headers\n}\nInvoke-RestMethod @params<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The $ApplicationName must contain the name of the application where you want to delete.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Delete_application_segment\"><\/span>Delete application segment<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$ApplicationName = \"New File Server\"\n$params = @{\n    Method = 'Get'\n    Uri = \"https:\/\/graph.microsoft.com\/beta\/applications\/?`$Filter=displayname eq '$ApplicationName'\"\n    Headers = $Headers\n}\n$App = Invoke-RestMethod @params\n$AppId = $App.value.id\n\n$ApplicationSegmentName = \"srvfile.domain.com\"\n$params = @{\n    Method = 'Get'\n    Uri = \"https:\/\/graph.microsoft.com\/beta\/applications\/$AppId\/onPremisesPublishing\/segmentsConfiguration\/microsoft.graph.IpSegmentConfiguration\/ApplicationSegments?`$Filter=destinationHost eq '$ApplicationSegmentName'\"\n    Headers = $Headers\n}\n$AppSegment = Invoke-RestMethod @params\n$AppSegmentId = $AppSegment.value.id\n\n$params = @{\n    Method = 'Delete'\n    Uri = \"https:\/\/graph.microsoft.com\/beta\/applications\/$AppId\/onPremisesPublishing\/segmentsConfiguration\/microsoft.graph.IpSegmentConfiguration\/ApplicationSegments\/$AppSegmentId\"\n    Headers = $Headers\n}\nInvoke-RestMethod @params<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The $ApplicationName must contain the name of the application where you want to delete an application segment. The $ApplicationSegmentName must contain the name of the application segment.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This introduction to Microsoft Graph API has been very fun and informative even though my learning curve was very steep. Microsoft Graph API is another &#8220;tool&#8221; in my &#8220;automation toolbox&#8221; and it will certainly have more of my attention in the future.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This concludes the article. Feel free to reach out to me on\u00a0<a href=\"https:\/\/twitter.com\/KasperMJohansen\">X<\/a>\u00a0or on\u00a0<a href=\"https:\/\/www.linkedin.com\/in\/kaspermjohansen\/\">LinkedIn<\/a>\u00a0if you have any comments or questions.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Automation has been a large part of my career as a consultant. Small scripts to solve mundane tasks during user logon or Windows startup is a way of automating tasks, &#8230;<\/p>\n","protected":false},"author":2,"featured_media":2226,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[36,32,33],"tags":[],"class_list":["post-2156","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-graph-api","category-scripts","category-secure-remote-access"],"_links":{"self":[{"href":"https:\/\/kasperjohansen.net\/index.php\/wp-json\/wp\/v2\/posts\/2156","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kasperjohansen.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kasperjohansen.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kasperjohansen.net\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/kasperjohansen.net\/index.php\/wp-json\/wp\/v2\/comments?post=2156"}],"version-history":[{"count":14,"href":"https:\/\/kasperjohansen.net\/index.php\/wp-json\/wp\/v2\/posts\/2156\/revisions"}],"predecessor-version":[{"id":2240,"href":"https:\/\/kasperjohansen.net\/index.php\/wp-json\/wp\/v2\/posts\/2156\/revisions\/2240"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kasperjohansen.net\/index.php\/wp-json\/wp\/v2\/media\/2226"}],"wp:attachment":[{"href":"https:\/\/kasperjohansen.net\/index.php\/wp-json\/wp\/v2\/media?parent=2156"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kasperjohansen.net\/index.php\/wp-json\/wp\/v2\/categories?post=2156"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kasperjohansen.net\/index.php\/wp-json\/wp\/v2\/tags?post=2156"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}