{"id":120,"date":"2016-06-21T10:49:43","date_gmt":"2016-06-21T09:49:43","guid":{"rendered":"http:\/\/www.kneefel-ict.nl\/?post_type=kbe_knowledgebase&#038;p=120"},"modified":"2016-07-19T07:38:04","modified_gmt":"2016-07-19T06:38:04","slug":"read-variables-from-xml-file","status":"publish","type":"kbe_knowledgebase","link":"https:\/\/kneefel-ict.nl\/en\/knowledgebase\/read-variables-from-xml-file\/","title":{"rendered":"PowerShell: Read variables from xml-file"},"content":{"rendered":"<p>Create an xml-file with the following content and save it as config.xml:<\/p>\n<pre>&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\r\n&lt;configuration&gt;\r\n  &lt;General&gt;\r\n    &lt;Domain&gt;test.local&lt;\/Domain&gt;\r\n    &lt;Environment&gt;development&lt;\/Environment&gt;\r\n  &lt;\/General&gt;\r\n  &lt;Users&gt;\r\n    &lt;User1&gt;John Doe&lt;\/User1&gt;\r\n    &lt;User2&gt;Jane Doe&lt;\/User2&gt;\r\n  &lt;\/Users&gt;\r\n  &lt;Groups&gt;\r\n    &lt;Group1&gt;Developers&lt;\/Group1&gt;\r\n    &lt;Group2&gt;Managers&lt;\/Group2&gt;\r\n  &lt;\/Groups&gt;\r\n&lt;\/configuration&gt;\r\n<\/pre>\n<p>Create a powershellscript with the following content and save it in the same folder:<\/p>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\">\r\n$ScriptPath = Split-Path -parent $PSCommandPath\r\n$ConfigFile = &quot;$ScriptPath\\config.xml&quot;\r\n\r\n$ConfigFileExists = Test-Path $ConfigFile\r\nIf ($ConfigFileExists -eq $False)\r\n{\r\n\twrite-host -f red &quot;Configfile $ConfigFile does not exist!&quot;\r\n\texit\r\n}\r\n\r\n&#x5B;xml]$Config = (Get-Content $ConfigFile)\r\n$Domain  = $Config.Configuration.General.Domain\r\n$Environment  = $Config.Configuration.General.Environment\r\n$User1  = $Config.Configuration.Users.User1\r\n$User2  = $Config.Configuration.Users.User2\r\n$Group1  = $Config.Configuration.Groups.Group1\r\n$Group2  = $Config.Configuration.Groups.Group2\r\n\r\n$Domain\r\n$Environment\r\n$User1\r\n$User2\r\n$Group1\r\n$Group2\r\n<\/pre>\n<p>If you run the powershellscript the output is<br \/>\ntest.local<br \/>\ndevelopment<br \/>\nJohn Doe<br \/>\nJane Doe<br \/>\nDevelopers<br \/>\nManagers<\/p>","protected":false},"excerpt":{"rendered":"<p>Create an xml-file with the following content and save it as config.xml: &lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;utf-8&#8243;?&gt; &lt;configuration&gt; &lt;General&gt; &lt;Domain&gt;test.local&lt;\/Domain&gt; &lt;Environment&gt;development&lt;\/Environment&gt; &lt;\/General&gt; &lt;Users&gt; &lt;User1&gt;John Doe&lt;\/User1&gt; &lt;User2&gt;Jane Doe&lt;\/User2&gt; &lt;\/Users&gt; &lt;Groups&gt; &lt;Group1&gt;Developers&lt;\/Group1&gt; &lt;Group2&gt;Managers&lt;\/Group2&gt; &lt;\/Groups&gt; &lt;\/configuration&gt; Create a powershellscript with the following content and save it in the same folder: $ScriptPath = Split-Path -parent $PSCommandPath $ConfigFile = &quot;$ScriptPath\\config.xml&quot; $ConfigFileExists = &hellip; <a href=\"https:\/\/kneefel-ict.nl\/en\/knowledgebase\/read-variables-from-xml-file\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;PowerShell: Read variables from xml-file&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","kbe_taxonomy":[4],"kbe_tags":[10,14],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>PowerShell: Read variables from xml-file - Kneefel ICT B.V.<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/kneefel-ict.nl\/knowledgebase\/read-variables-from-xml-file\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"PowerShell: Read variables from xml-file - Kneefel ICT B.V.\" \/>\n<meta property=\"og:description\" content=\"Create an xml-file with the following content and save it as config.xml: &lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt; &lt;configuration&gt; &lt;General&gt; &lt;Domain&gt;test.local&lt;\/Domain&gt; &lt;Environment&gt;development&lt;\/Environment&gt; &lt;\/General&gt; &lt;Users&gt; &lt;User1&gt;John Doe&lt;\/User1&gt; &lt;User2&gt;Jane Doe&lt;\/User2&gt; &lt;\/Users&gt; &lt;Groups&gt; &lt;Group1&gt;Developers&lt;\/Group1&gt; &lt;Group2&gt;Managers&lt;\/Group2&gt; &lt;\/Groups&gt; &lt;\/configuration&gt; Create a powershellscript with the following content and save it in the same folder: $ScriptPath = Split-Path -parent $PSCommandPath $ConfigFile = &quot;$ScriptPathconfig.xml&quot; $ConfigFileExists = &hellip; Continue reading &quot;PowerShell: Read variables from xml-file&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/kneefel-ict.nl\/knowledgebase\/read-variables-from-xml-file\/\" \/>\n<meta property=\"og:site_name\" content=\"Kneefel ICT B.V.\" \/>\n<meta property=\"article:modified_time\" content=\"2016-07-19T06:38:04+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/kneefel-ict.nl\/knowledgebase\/read-variables-from-xml-file\/\",\"url\":\"https:\/\/kneefel-ict.nl\/knowledgebase\/read-variables-from-xml-file\/\",\"name\":\"PowerShell: Read variables from xml-file - Kneefel ICT B.V.\",\"isPartOf\":{\"@id\":\"https:\/\/kneefel-ict.nl\/#website\"},\"datePublished\":\"2016-06-21T09:49:43+00:00\",\"dateModified\":\"2016-07-19T06:38:04+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/kneefel-ict.nl\/knowledgebase\/read-variables-from-xml-file\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/kneefel-ict.nl\/knowledgebase\/read-variables-from-xml-file\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/kneefel-ict.nl\/knowledgebase\/read-variables-from-xml-file\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/kneefel-ict.nl\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Knowledgebase\",\"item\":\"https:\/\/kneefel-ict.nl\/en\/knowledgebase\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"PowerShell: Read variables from xml-file\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/kneefel-ict.nl\/#website\",\"url\":\"https:\/\/kneefel-ict.nl\/\",\"name\":\"Kneefel ICT B.V.\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/kneefel-ict.nl\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/kneefel-ict.nl\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/kneefel-ict.nl\/#organization\",\"name\":\"Kneefel ICT B.V.\",\"url\":\"https:\/\/kneefel-ict.nl\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/kneefel-ict.nl\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/i1.wp.com\/www.kneefel-ict.nl\/wp-content\/uploads\/2016\/01\/logo_kneefel-ict-1200x280dpi.jpg?fit=1200%2C280&ssl=1\",\"contentUrl\":\"https:\/\/i1.wp.com\/www.kneefel-ict.nl\/wp-content\/uploads\/2016\/01\/logo_kneefel-ict-1200x280dpi.jpg?fit=1200%2C280&ssl=1\",\"width\":1200,\"height\":280,\"caption\":\"Kneefel ICT B.V.\"},\"image\":{\"@id\":\"https:\/\/kneefel-ict.nl\/#\/schema\/logo\/image\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"PowerShell: Read variables from xml-file - Kneefel ICT B.V.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/kneefel-ict.nl\/knowledgebase\/read-variables-from-xml-file\/","og_locale":"en_US","og_type":"article","og_title":"PowerShell: Read variables from xml-file - Kneefel ICT B.V.","og_description":"Create an xml-file with the following content and save it as config.xml: &lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt; &lt;configuration&gt; &lt;General&gt; &lt;Domain&gt;test.local&lt;\/Domain&gt; &lt;Environment&gt;development&lt;\/Environment&gt; &lt;\/General&gt; &lt;Users&gt; &lt;User1&gt;John Doe&lt;\/User1&gt; &lt;User2&gt;Jane Doe&lt;\/User2&gt; &lt;\/Users&gt; &lt;Groups&gt; &lt;Group1&gt;Developers&lt;\/Group1&gt; &lt;Group2&gt;Managers&lt;\/Group2&gt; &lt;\/Groups&gt; &lt;\/configuration&gt; Create a powershellscript with the following content and save it in the same folder: $ScriptPath = Split-Path -parent $PSCommandPath $ConfigFile = &quot;$ScriptPathconfig.xml&quot; $ConfigFileExists = &hellip; Continue reading \"PowerShell: Read variables from xml-file\"","og_url":"https:\/\/kneefel-ict.nl\/knowledgebase\/read-variables-from-xml-file\/","og_site_name":"Kneefel ICT B.V.","article_modified_time":"2016-07-19T06:38:04+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/kneefel-ict.nl\/knowledgebase\/read-variables-from-xml-file\/","url":"https:\/\/kneefel-ict.nl\/knowledgebase\/read-variables-from-xml-file\/","name":"PowerShell: Read variables from xml-file - Kneefel ICT B.V.","isPartOf":{"@id":"https:\/\/kneefel-ict.nl\/#website"},"datePublished":"2016-06-21T09:49:43+00:00","dateModified":"2016-07-19T06:38:04+00:00","breadcrumb":{"@id":"https:\/\/kneefel-ict.nl\/knowledgebase\/read-variables-from-xml-file\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/kneefel-ict.nl\/knowledgebase\/read-variables-from-xml-file\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/kneefel-ict.nl\/knowledgebase\/read-variables-from-xml-file\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/kneefel-ict.nl\/"},{"@type":"ListItem","position":2,"name":"Knowledgebase","item":"https:\/\/kneefel-ict.nl\/en\/knowledgebase\/"},{"@type":"ListItem","position":3,"name":"PowerShell: Read variables from xml-file"}]},{"@type":"WebSite","@id":"https:\/\/kneefel-ict.nl\/#website","url":"https:\/\/kneefel-ict.nl\/","name":"Kneefel ICT B.V.","description":"","publisher":{"@id":"https:\/\/kneefel-ict.nl\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/kneefel-ict.nl\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/kneefel-ict.nl\/#organization","name":"Kneefel ICT B.V.","url":"https:\/\/kneefel-ict.nl\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/kneefel-ict.nl\/#\/schema\/logo\/image\/","url":"https:\/\/i1.wp.com\/www.kneefel-ict.nl\/wp-content\/uploads\/2016\/01\/logo_kneefel-ict-1200x280dpi.jpg?fit=1200%2C280&ssl=1","contentUrl":"https:\/\/i1.wp.com\/www.kneefel-ict.nl\/wp-content\/uploads\/2016\/01\/logo_kneefel-ict-1200x280dpi.jpg?fit=1200%2C280&ssl=1","width":1200,"height":280,"caption":"Kneefel ICT B.V."},"image":{"@id":"https:\/\/kneefel-ict.nl\/#\/schema\/logo\/image\/"}}]}},"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/kneefel-ict.nl\/en\/wp-json\/wp\/v2\/kbe_knowledgebase\/120"}],"collection":[{"href":"https:\/\/kneefel-ict.nl\/en\/wp-json\/wp\/v2\/kbe_knowledgebase"}],"about":[{"href":"https:\/\/kneefel-ict.nl\/en\/wp-json\/wp\/v2\/types\/kbe_knowledgebase"}],"author":[{"embeddable":true,"href":"https:\/\/kneefel-ict.nl\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kneefel-ict.nl\/en\/wp-json\/wp\/v2\/comments?post=120"}],"version-history":[{"count":2,"href":"https:\/\/kneefel-ict.nl\/en\/wp-json\/wp\/v2\/kbe_knowledgebase\/120\/revisions"}],"predecessor-version":[{"id":147,"href":"https:\/\/kneefel-ict.nl\/en\/wp-json\/wp\/v2\/kbe_knowledgebase\/120\/revisions\/147"}],"wp:attachment":[{"href":"https:\/\/kneefel-ict.nl\/en\/wp-json\/wp\/v2\/media?parent=120"}],"wp:term":[{"taxonomy":"kbe_taxonomy","embeddable":true,"href":"https:\/\/kneefel-ict.nl\/en\/wp-json\/wp\/v2\/kbe_taxonomy?post=120"},{"taxonomy":"kbe_tags","embeddable":true,"href":"https:\/\/kneefel-ict.nl\/en\/wp-json\/wp\/v2\/kbe_tags?post=120"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}