Handle UNC paths
See original issue record on blog; not sure of exact issue.
Check details from users here: http://danspowershellstuff.blogspot.com/2012/03/powershell-pretty-printer-code-cleaner.html
I have worked around this issue by wrapping it in a function that moves it local then runs Edit-DTWBeautifyScript
I am also using this function found here https://stackoverflow.com/questions/8789870/powershell-ise-doesnt-refresh-modification-done-outside
function Reload { $CurrentFile = $psise.CurrentFile $FilePath = $CurrentFile.FullPath $lineNum = $psise.CurrentFile.Editor.CaretLine $colNum = $psise.CurrentFile.Editor.CaretColumn $PsISE.CurrentPowerShellTab.Files.remove($CurrentFile) > $null $newFile = $PsISE.CurrentPowerShellTab.Files.add($FilePath) $newfile.Editor.SetCaretPosition($lineNum,$colNum) } $psISE.CurrentPowerShellTab.AddOnsMenu.SubMenus.Clear() $psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.Add("Reload File",{Reload},'f4') > $null
Hey @justusiv Sorry I haven't looked into this one yet; I've been crazy busy. Hoping things quiet down for me in a few weeks and I'll have time to work on this.
In the meantime, have you tried VS Code with the PowerShell extension yet? I used to use ISE with ISESteroids (a great plug-in) but after trying VS Code I'm hooked. You do have to spend a some time learning how it works; basic editing and such is obvious but there are many hidden gems that you have to search for - my favorite is Show References Shift-F12. It's worth reading a few blogs about editing & debugging PowerShell in VS Code, you will definitely learn some new tricks. Also, VS Code gets a new release once a month or so - so it's constantly being updated with new functionality. There is one giant drawback; code folding doesn't currently work for regions, etc. They are working on this (see project Microsoft/vscode issues 3422) so perhaps the next release or two will fix it.
@DTW-DanWard Thanks for the reply. I will check it out when i get some time. I just tried ISESteroids this week and while i really liked it i ran into a few show stopping issues that i didnt want to troubleshoot. One example was code speed. As far as Beautifier goes i have it working exactly the way i want even with UNC paths. The function above i modified to move the file local run your code then move it back to where it was before. I popped that into my profile and away i go. I would be happy to post it but am not at the computer i set it up at.
@justusiv No problem. When I get time I can look into it; copying to local temp is straight-forward but I also want to check out the System.IO library a little more closely to make sure there isn't anything I'm missing that I could be doing.
@DTW-DanWard Absolutely. Its a work-around for sure but i am happy with it :) Thanks for your contributions :)