{"id":1017,"date":"2016-09-21T11:16:41","date_gmt":"2016-09-21T10:16:41","guid":{"rendered":"https:\/\/www.lieben.nu\/liebensraum\/?p=1017"},"modified":"2016-09-21T11:16:41","modified_gmt":"2016-09-21T10:16:41","slug":"ems-case-running-a-powershell-logonscript-like-onedrivemapper-on-azuread-joined-machines-through-intune","status":"publish","type":"post","link":"https:\/\/lieben.nu\/liebensraum\/2016\/09\/ems-case-running-a-powershell-logonscript-like-onedrivemapper-on-azuread-joined-machines-through-intune\/","title":{"rendered":"EMS Case: Running a Powershell Logonscript like OnedriveMapper on AzureAD joined machines through Intune"},"content":{"rendered":"<p><span style=\"color: #ff0000;\">NOTICE: it is easier to use <span style=\"color: #000080;\"><a style=\"color: #000080;\" href=\"https:\/\/docs.microsoft.com\/en-us\/intune\/intune-management-extension\" target=\"_blank\" rel=\"noopener\">Device Configuration Scripts<\/a> <\/span>now that this feature has been released in Intune.<\/span><\/p>\n<p>A second case, comparable to\u00a0<a href=\"https:\/\/www.lieben.nu\/liebensraum\/2016\/09\/ems-case-distributing-office-templates-and-macros-to-your-users-on-windows-10-mobile-managed-azure-ad-joined-devices\/\" target=\"_blank\" rel=\"noopener\">EMS case: distributing Office templates and macro&#8217;s to your users on Windows 10 mobile managed Azure AD Joined devices<\/a>.<\/p>\n<p>In this case I will show you how to package and distribute a Powershell script (<a href=\"https:\/\/www.lieben.nu\/liebensraum\/2016\/09\/onedrivemapper-v2-39-released\/\" target=\"_blank\" rel=\"noopener\">OnedriveMapper <\/a>in this case) through Intune to MDM enrolled Windows 10 devices.<\/p>\n<p><!--more--><\/p>\n<p>Requirements:<\/p>\n<ul>\n<li>A test user with an EMS licence (or seperate Azure AD Premium and Intune)<\/li>\n<li>Source\u00a0file of the script<\/li>\n<li>Google<\/li>\n<li><a href=\"http:\/\/www.advancedinstaller.com\/\">Advanced Installer<\/a> (free license)<\/li>\n<\/ul>\n<p>Steps:<\/p>\n<p>First, let&#8217;s start a &#8216;Simple&#8217; project in Advanced Installer, this does not require a license. Navigate to Files and Folders and create a Program Files folder for your script, add your script there. My script also writes a log file, so I also created a folder for the script under Application Data to keep user specific logs:<\/p>\n<p><a href=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2016\/09\/om_1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1019\" src=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2016\/09\/om_1.png\" alt=\"om_1\" width=\"1037\" height=\"562\" srcset=\"https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2016\/09\/om_1.png 1037w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2016\/09\/om_1-300x163.png 300w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2016\/09\/om_1-1024x555.png 1024w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2016\/09\/om_1-768x416.png 768w\" sizes=\"auto, (max-width: 1037px) 100vw, 1037px\" \/><\/a><\/p>\n<p>Now we can set a registry to automatically run this script upon login (the famous &#8216;Run&#8217; key):<\/p>\n<p><a href=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2016\/09\/om_2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1020\" src=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2016\/09\/om_2.png\" alt=\"om_2\" width=\"1884\" height=\"610\" srcset=\"https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2016\/09\/om_2.png 1884w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2016\/09\/om_2-300x97.png 300w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2016\/09\/om_2-1024x332.png 1024w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2016\/09\/om_2-768x249.png 768w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2016\/09\/om_2-1536x497.png 1536w\" sizes=\"auto, (max-width: 1884px) 100vw, 1884px\" \/><\/a><\/p>\n<p>As the screenshot should show, I&#8217;ve added a REG_SZ key under HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run with the name of my script, and execution instructions as the parameter. Advanced Installer has a nice option to insert the final file path upon MSI installation (&#8216;File&#8217; button). Be sure to enclose in quotes, as the path may include spaces:<\/p>\n<p>Powershell.exe -WindowStyle Hidden -ExecutionPolicy ByPass -File &#8220;[#OneDriveMapper_v2_41.ps1]&#8221;<\/p>\n<p>Now, OnedriveMapper also requires a few additional settings I won&#8217;t screenshot but will list here seperately, configuring these will let the script run smoothly:<\/p>\n<ul>\n<li>HKLM\\Software\\Policies\\Microsoft\\Internet Explorer\\Main\\DisableFirstRunCustomize (DWORD, value 1)<\/li>\n<li>HKCU\\Software\\Policies\\Microsoft\\Internet Explorer\\Main\\DisableFirstRunCustomize (DWORD, value 1)<\/li>\n<li>HKLM\\System\\CurrentControlSet\\Services\\Webclient\\Start (DWORD, value 2)<\/li>\n<li>HKLM\\System\\CurrentControlSet\\Services\\Webclient\\Parameters\\FileSizeLimitInBytes (DWORD, value 3221225472)<\/li>\n<li>HKLM\\System\\CurrentControlSet\\Services\\Webclient\\Parameters\\ServerNotFoundCacheLifetimeInSec\u00a0(DWORD, value 10)<\/li>\n<li>HKLM\\System\\CurrentControlSet\\Services\\Webclient\\Parameters\\SupportLocking\u00a0(DWORD, value 0)<\/li>\n<\/ul>\n<p>I then also copied the first key that causes the script to run to the HKEY_USERS\\.DEFAULT section, this will ensure the script also works for users who have never logged onto the machine.<\/p>\n<p><a href=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2016\/09\/om_3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1021\" src=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2016\/09\/om_3.png\" alt=\"om_3\" width=\"640\" height=\"414\" srcset=\"https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2016\/09\/om_3.png 640w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2016\/09\/om_3-300x194.png 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p>Now configure the Install Parameters:<\/p>\n<p><a href=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2016\/09\/om_4.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1022\" src=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2016\/09\/om_4.png\" alt=\"om_4\" width=\"955\" height=\"595\" srcset=\"https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2016\/09\/om_4.png 955w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2016\/09\/om_4-300x187.png 300w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2016\/09\/om_4-768x478.png 768w\" sizes=\"auto, (max-width: 955px) 100vw, 955px\" \/><\/a><\/p>\n<p><strong>Note:\u00a0<\/strong><em>if you&#8217;re deploying OnedriveMapper to a clean device, I recommend forcing a reboot after install to ensure the WebDav client actually starts.<\/em><\/p>\n<p>Now just press the build button in the top left and you&#8217;ll end up with a single, clean and working MSI file. Log in to the <a href=\"https:\/\/manage.microsoft.com\/microsoftIntune\/\">Intune console<\/a>, and go to the Apps section.<\/p>\n<p>Click Add Apps and load the on demand configuration tool:<\/p>\n<p><a href=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2016\/09\/ai_templates_6.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1001\" src=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2016\/09\/ai_templates_6.png\" alt=\"ai_templates_6\" width=\"415\" height=\"133\" srcset=\"https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2016\/09\/ai_templates_6.png 415w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2016\/09\/ai_templates_6-300x96.png 300w\" sizes=\"auto, (max-width: 415px) 100vw, 415px\" \/><\/a><\/p>\n<p>Ensure you have selected &#8220;Windows Installer through MDM&#8221;, the other methods won&#8217;t work.<\/p>\n<p><a href=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2016\/09\/ai_templates_7.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1002\" src=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2016\/09\/ai_templates_7.png\" alt=\"ai_templates_7\" width=\"947\" height=\"656\" srcset=\"https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2016\/09\/ai_templates_7.png 947w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2016\/09\/ai_templates_7-300x208.png 300w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2016\/09\/ai_templates_7-768x532.png 768w\" sizes=\"auto, (max-width: 947px) 100vw, 947px\" \/><\/a><\/p>\n<p>Accept all other default settings or configure as you please and press Upload.<\/p>\n<p>Once the upload completes, you&#8217;ll see the app in the Intune Console, but this won&#8217;t distribute the application yet, for that you&#8217;ll have to click &#8216;Manage Deployment&#8221; and configure a user based deployment:<\/p>\n<p><a href=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2016\/09\/ai_templates_8.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1003\" src=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2016\/09\/ai_templates_8.png\" alt=\"ai_templates_8\" width=\"1319\" height=\"263\" srcset=\"https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2016\/09\/ai_templates_8.png 1319w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2016\/09\/ai_templates_8-300x60.png 300w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2016\/09\/ai_templates_8-1024x204.png 1024w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2016\/09\/ai_templates_8-768x153.png 768w\" sizes=\"auto, (max-width: 1319px) 100vw, 1319px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2016\/09\/ai_templates_9.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1004\" src=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2016\/09\/ai_templates_9.png\" alt=\"ai_templates_9\" width=\"1542\" height=\"330\" srcset=\"https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2016\/09\/ai_templates_9.png 1542w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2016\/09\/ai_templates_9-300x64.png 300w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2016\/09\/ai_templates_9-1024x219.png 1024w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2016\/09\/ai_templates_9-768x164.png 768w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2016\/09\/ai_templates_9-1536x329.png 1536w\" sizes=\"auto, (max-width: 1542px) 100vw, 1542px\" \/><\/a><a href=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2016\/09\/ai_templates_10.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1005\" src=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2016\/09\/ai_templates_10.png\" alt=\"ai_templates_10\" width=\"1334\" height=\"197\" srcset=\"https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2016\/09\/ai_templates_10.png 1334w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2016\/09\/ai_templates_10-300x44.png 300w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2016\/09\/ai_templates_10-1024x151.png 1024w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2016\/09\/ai_templates_10-768x113.png 768w\" sizes=\"auto, (max-width: 1334px) 100vw, 1334px\" \/><\/a><\/p>\n<p>And voila, within the hour your devices will have the script and registry keys, and the next time your user logs in the script will execute!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>NOTICE: it is easier to use Device Configuration Scripts now that this feature has been released in Intune. A second case, comparable to\u00a0EMS case: distributing Office templates and macro&#8217;s to your users on Windows 10 mobile managed Azure AD Joined devices. In this case I will show you how to package and distribute a Powershell &hellip; <a href=\"https:\/\/lieben.nu\/liebensraum\/2016\/09\/ems-case-running-a-powershell-logonscript-like-onedrivemapper-on-azuread-joined-machines-through-intune\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">EMS Case: Running a Powershell Logonscript like OnedriveMapper on AzureAD joined machines through Intune<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","footnotes":""},"categories":[22,32,35,39],"tags":[],"class_list":["post-1017","post","type-post","status-publish","format-standard","hentry","category-intune","category-office-365","category-onedrivemapper","category-powershell"],"_links":{"self":[{"href":"https:\/\/lieben.nu\/liebensraum\/wp-json\/wp\/v2\/posts\/1017","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lieben.nu\/liebensraum\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lieben.nu\/liebensraum\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lieben.nu\/liebensraum\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lieben.nu\/liebensraum\/wp-json\/wp\/v2\/comments?post=1017"}],"version-history":[{"count":0,"href":"https:\/\/lieben.nu\/liebensraum\/wp-json\/wp\/v2\/posts\/1017\/revisions"}],"wp:attachment":[{"href":"https:\/\/lieben.nu\/liebensraum\/wp-json\/wp\/v2\/media?parent=1017"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lieben.nu\/liebensraum\/wp-json\/wp\/v2\/categories?post=1017"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lieben.nu\/liebensraum\/wp-json\/wp\/v2\/tags?post=1017"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}