Microsoft Teams and Skype for Business News and Thoughts

Tom Arbuthnot MVP
Tom Arbuthnot MCSM Communications

This site uses cookies

Find this blog useful? Please take a second to share, thanks!

Run PowerShell Scripts Directly from GitHub with Two Lines

Published 07/02/2016 - 1 Comment

First off, this is a really bad idea most of the time. You shouldn’t run scripts on your system you don’t understand/haven’t reviewed and that someone else could edit at any time.

However, it is possible to pull scripts directly from GitHub and run them on a system. Allowing you to use 2 simple lines to invoke a larger script, and to pull the latest version of a script every time.

What we are doing here is using Invoke-WebRequest to get the GitHub “RAW” file from the master branch, which should always be the “current” script, then we are using Invoke-Expression to run that Script

$ScriptFromGitHub = Invoke-WebRequest
Invoke-Expression $($ScriptFromGitHub.Content)

In this case, the script we are pulling is: , which is just a little sample script



  • Anyone who has the rights to change the source on GitHub could change it at any time. This means you always pull the latest script, but also means they could change the script to format your C:\ Drive, so think carefully about if/how you use this

If you see this error when you try to do this:


It might be that GitHub has inserted a “.” before your first line, you can remove it with the GitHub web editor.


Tom Arbuthnot

Tom Arbuthnot

Principal Solutions Architect at Modality Systems
Tom Arbuthnot is Principal Solutions Architect at Unified Communications specialist Modality Systems. He is a Microsoft Certified Master and MVP, blogger, has a regular podcast with UCToday at and is a regular speaker at events including Microsoft TechEd and Ignite. He co-runs The Microsoft UC User Group London.

1 comment

PowerShell Schnipseljagd 14/18 | | PowerShell Usergroup Austria - 06/04/2018 Reply

[…] Ich selber hätte da kein gutes Gefühl – aber natürlich eine witzige Idee. PowerShell direkt von Github starten in 2 Zeilen. […]

Leave a Reply:


Weekly Email Update 
of all the key 
Microsoft Teams and Skype for Business News
every Tuesday

No Spam ever, I promise - Tom