The extension is definitely worth including it in the official version of VS, which happens to be a very decent IDE and text editor -text being the very DNA of everything we do when making software. Kudos to Adam for this fine work ;-)
Well done and a massive thank you Adam. I have been using this on a large powershell codebase and its been very stable (v0.5). Already a large improvement over PowerGUI and Powershell ISE. Trying out the new version now. Please do keep it up! -Naeem
Thanks, been looking for something like this. It seems that text inside a comment block (<#...#>) is not being colored as comments. The script will execute fine as far as I can tell so it seems to know those lines are comments but it's a little distracting. Not a big deal since I can collapse the block but just wanted to share. Thanks again for the work on this.
I believe this extension would be great, but I use dark theme and it is completely unusable. There needs to be an alternate set of colors for syntax highlighting that works well on a dark theme text editor window.
Awesome extension for Visual Studio if you write PowerShell scripts. VS brings with it inherent features like source control integration, inline find/find&replace, scrollbar map, etc that ISE just doesn't have yet. Heck this extension's function navigation feature alone makes it a must have for PowerShell script editing.
There isn't currently built in support for this. Although, there is an issue on GitHub open for this very scenario. For the time being, you can add another script that calls the script you are trying to debug, passing in the arguments and execute that script instead.
I'm having the same problem as a.sarafian is.
If I try to do the steps in your link I can't create a new powershell script project (this may be because I'm using team explorer for VS 2012). If I right-click in a .ps1 file and click 'execute as script' I get the error "Error HRESULT E_FAIL has been returned from a call to a COM component."
Ok, installed Powershell Tools for Visual Studio. Now, please excuse a N00b Question, how do I benefit from this Visual Studio integration if i would like to add a GUI to my powershell script?
Great work Adam BTW!
Thanks! Sorry to disappoint but there is not designer support for the GUI with this extension (yet?). It would be a really great addition but I think the Sapien PowerShell Studio is the only product that supports something like that.
Great app, we use it in our Windows 7 SP1 with PoSH 3.0 VS2013 Premium build and it's a fan favorite. We're trying to move to Windows 8.1 (which includes WMF/PoSH 4.0 by default) and I was wondering if this would still work as well in there, or if we need to wait for a future release that will support PoSH 4.0? Thanks in advance for the reply!
Glad you dig it! I've been using (and developing) the extension on Windows 8.1 for the last couple weeks. I'd recommend testing in your environment but the APIs used for this extension are very similar between v3 and v4.
Really nice to see this level of PowerShell support in VS2012. But as a developer I try to test everything. I added Pester as a Nuget package to my solution, but is there any level of Pester integration so "building" the solution will run my Pester tests?
There currently isn't any support for Pester. It would be great to integrate it into the unit test runner. I'd suggest submitting a GitHub issue about it to track it. Thanks for the suggestion!
I actually entered an item. I really like this idea. Could use the test adapter API to have the tests exposed through the test explorer window.
Thanks for you great job, Adam,
I am trying to apply Add-PSSnapin "Microsoft.SharePoint.PowerShell", but get error like:
Add-PSSnapin : The Windows PowerShell snap-in 'Microsoft.SharePoint.PowerShell' is not installed on this computer.
when I run this on my normal Powershell editor, I don't have this issue, can you please give me some ideas how to solve this problem.
Appreciate your help a lot.
The problem with the SharePoint snap-in is that it is built for the x64 architecture. Visual Studio is an x86 application so it cannot actually load the snap-in. This is why it can't find it either. The regular PowerShell.exe or ISE can run either x86 or x64. It's x64 by default.
The best we could do here is run a local-remote session to host the x64 runtime but I haven't tried this at all. With remote debugging available in PowerShell v4 this may be a viable option.
Fixing the project system and snippets are next on the docket. The big thing is creating MSBuild targets that can accommodate an output folder like that. Right now it simply doesn't work.
Please submit an issue on GitHub so that we can track and prioritize.
I am using VS 2013 and I got the following error:
Error: File F:\ADExample.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at http://go.microsoft.com/fwlink/?LinkID=135170.
The program 'ADExample.ps1: PowerShell Script' has exited with code 0 (0x0).
I have tried to open powershell command prompt as admin and executed Set-ExecutionPolicy Unrestricted -Force and still it can't run.
There is now an option to have PSVS bypass the execution policy. If you go into Tools->Options->PowerShell Tools->General and set Override Execution Policy Configuration, it should bypass this. You'll have to restart Visual Studio.
The reason it may not have worked from PowerShell is that you didn't run the x86 console.
After downloading and installing, at VS startup get a message "The 'PowerShellToolsPackage' package did not load correctly...". ActivityLog has the following:
Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
*** followed by this error 4 times ****
Could not load file or assembly 'System.Management.Automation, Version=220.127.116.11, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
You are correct, PS 3 not installed because in our case they are SharePoint 2010 dev servers and SharePoint 2010 and PS 3 don't play nice. Outside of SP 2010 boxes though loading PS 3 solved this problem.
I love this extension and have been using it fine with VS2012 but I get the following errors logged in the ActivityLog.xml when starting VS2013 premium on Win 8 Enterprise 64Bit and there is no syntax highlighting:
System.NullReferenceException: Object reference not set to an instance of an object. at PowerShellTools.Classification.PowerShellErrorTagger.<GetTags>d__0.MoveNext() at Microsoft.VisualStudio.Text.Tagging.Implementation.TagAggregator`1.<GetTagsForBuffer>d__5.MoveNext()
System.Collections.Generic.KeyNotFoundException: key at Microsoft.VisualStudio.Utilities.PropertyCollection.GetProperty(Object key) at PowerShellTools.Classification.PowerShellClassifier.AddTokenClassifications(ITextBuffer buffer, SnapshotSpan span, List`1 classifications, Nullable`1 lastClassificationSpan, IClassificationType gapType) at PowerShellTools.Classification.PowerShellClassifier.VirtualGetClassificationSpans(SnapshotSpan span) at PowerShellTools.Classification.ISEClassifier.GetClassificationSpans(SnapshotSpan span) at Microsoft.VisualStudio.Text.Classification.Implementation.ClassifierTagger.<GetTags>d__0.MoveNext() at Microsoft.VisualStudio.Text.Tagging.Implementation.TagAggregator`1.<GetTagsForBuffer>d__5.MoveNext()
I can't reproduce this problem. I'll see if I can code defensively in the area you specified but I would probably need some more information on the project and script you are working with to really get it sorted out.
I have just updated the extension in VS2013 and it's working now. Whether it was a code change or just not installed properly I'm not sure. I originally installed it in VS2012 and it appeared to be installed for VS2013 as well. Perhaps I needed to install it individually in each VS?
Anyway, thanks a lot. It's a great extension.