Site icon TechZilica ~ On the Edge

The best way to run PowerShell Scripts on ConnectWise Automate

PowerShell icon

&Tab;&Tab;<div data-elementor-type&equals;"wp-post" data-elementor-id&equals;"684" class&equals;"elementor elementor-684" data-elementor-post-type&equals;"post">&NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;<section class&equals;"elementor-section elementor-top-section elementor-element elementor-element-ad46661 elementor-section-boxed elementor-section-height-default elementor-section-height-default" data-id&equals;"ad46661" data-element&lowbar;type&equals;"section">&NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;<div class&equals;"elementor-container elementor-column-gap-default">&NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;<div class&equals;"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-3d79eec" data-id&equals;"3d79eec" data-element&lowbar;type&equals;"column">&NewLine;&Tab;&Tab;&Tab;<div class&equals;"elementor-widget-wrap elementor-element-populated">&NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;<div class&equals;"elementor-element elementor-element-669c198 elementor-widget elementor-widget-heading" data-id&equals;"669c198" data-element&lowbar;type&equals;"widget" data-widget&lowbar;type&equals;"heading&period;default">&NewLine;&Tab;&Tab;&Tab;&Tab;<div class&equals;"elementor-widget-container">&NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;<h2 class&equals;"elementor-heading-title elementor-size-default">Intro<&sol;h2>&Tab;&Tab;&Tab;&Tab;<&sol;div>&NewLine;&Tab;&Tab;&Tab;&Tab;<&sol;div>&NewLine;&Tab;&Tab;&Tab;&Tab;<div class&equals;"elementor-element elementor-element-f2b0fae elementor-widget elementor-widget-text-editor" data-id&equals;"f2b0fae" data-element&lowbar;type&equals;"widget" data-widget&lowbar;type&equals;"text-editor&period;default">&NewLine;&Tab;&Tab;&Tab;&Tab;<div class&equals;"elementor-widget-container">&NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;<p>Starting my journey using ConnectWise Automate&comma; I quickly realised the most obvious way of running PowerShell scripts&comma; natively in the ConnectWise Automate scripting language frequently results in scripts never finishing or only partly executing&comma; I&&num;8217&semi;ve spent hours troubleshooting and found the best way to run PowerShell scripts in Automate&excl;<&sol;p><p>This info is the result of hours of my struggle&excl; 😊<&sol;p>&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;<&sol;div>&NewLine;&Tab;&Tab;&Tab;&Tab;<&sol;div>&NewLine;&Tab;&Tab;&Tab;&Tab;<div class&equals;"elementor-element elementor-element-5cc6bfa elementor-widget elementor-widget-heading" data-id&equals;"5cc6bfa" data-element&lowbar;type&equals;"widget" data-widget&lowbar;type&equals;"heading&period;default">&NewLine;&Tab;&Tab;&Tab;&Tab;<div class&equals;"elementor-widget-container">&NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;<h2 class&equals;"elementor-heading-title elementor-size-default">Method<&sol;h2>&Tab;&Tab;&Tab;&Tab;<&sol;div>&NewLine;&Tab;&Tab;&Tab;&Tab;<&sol;div>&NewLine;&Tab;&Tab;&Tab;&Tab;<div class&equals;"elementor-element elementor-element-2379d1e elementor-widget elementor-widget-text-editor" data-id&equals;"2379d1e" data-element&lowbar;type&equals;"widget" data-widget&lowbar;type&equals;"text-editor&period;default">&NewLine;&Tab;&Tab;&Tab;&Tab;<div class&equals;"elementor-widget-container">&NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;<p>I find the best solution to creating complex scripts in ConnectWise Automate&comma; is to avoid the in-built features as much as possible and rely as much as you can on writing text files to the computer&semi; then having the computer run those text files as PowerShell scripts natively&comma; &lpar;You want to avoid the built-in Automate PowerShell too&rpar;&period;<&sol;p><p>So how do we do this&quest;<&sol;p><p>The first step is to develop your PowerShell script &lpar;You should do this in your own testing environment and away from Automate&rpar;&comma; it will take you considerably longer to find issues in your code when trying to execute a script on Automate&period;<&sol;p><p>Once your PowerShell code is developed and fully tested&comma; you should create your Automate script&comma; so that it writes your PowerShell script as a text file &lpar;with the &period;ps1 extension&rpar; to the computer&period; I find writing to &&num;8216&semi;C&colon;&bsol;Windows&bsol;temp&&num;8217&semi; to the be the best location &&num;8211&semi;<&sol;p><p><img class&equals;"alignnone size-large wp-image-687" src&equals;"http&colon;&sol;&sol;techzilica&period;com&sol;wp-content&sol;uploads&sol;2022&sol;09&sol;ConnectWise-write-script-to-PC-1024x408&period;png" alt&equals;"Writing ConnectWise Automate PowerShell script to the PC" width&equals;"1024" height&equals;"408" &sol;><&sol;p><p>Now you&&num;8217&semi;ve got the script file written to the PC&comma; you need to call the script and get it to execute on the PC&comma; so the next step is executing the script file you&&num;8217&semi;ve just written&colon;<br &sol;><img class&equals;"alignnone size-large wp-image-688" src&equals;"http&colon;&sol;&sol;techzilica&period;com&sol;wp-content&sol;uploads&sol;2022&sol;09&sol;ConnectWise-execute-script-thats-on-the-target-PC-1024x311&period;png" alt&equals;"" width&equals;"1024" height&equals;"311" &sol;><&sol;p><p>Thats it&excl; it&&num;8217&semi;s really that simple&comma; so if you&&num;8217&semi;ve had issues with running PowerShell on ConnectWise Automate endpoints&comma; try this&comma; it should resolve all your problems&excl;<&sol;p><p>Remember&comma; it is really important to debug your PowerShell code before involving Automate in the process&comma; this will save you hours&period;<&sol;p><p> <&sol;p><h5><a href&equals;"https&colon;&sol;&sol;mega&period;nz&sol;file&sol;6IhGCJ7C&num;uwWerUSdCJ724mRzigUSH1q2VBc&lowbar;WYzmpSfrQQ5BWg8">You can download my script referenced in this article here&period;<&sol;a><&sol;h5>&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;<&sol;div>&NewLine;&Tab;&Tab;&Tab;&Tab;<&sol;div>&NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;<&sol;div>&NewLine;&Tab;&Tab;<&sol;div>&NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;<&sol;div>&NewLine;&Tab;&Tab;<&sol;section>&NewLine;&Tab;&Tab;&Tab;&Tab;<&sol;div>&NewLine;&Tab;&Tab;

Exit mobile version