Ramon Tan liked the comment of Michael Pietroforte (Rank: Level 4)
on PowerShell v5 vs. PowerShell v7—Which to use and when. (So far, Michael Pietroforte (Rank: Level 4)
has 2 likes for this comment) 1 year, 6 months agoRamon Tan started the topic Powershell 7 does not recognize the Cells() Excel method in
PowerShell Forum 2 years, 2 months ago
I have several scripts under PS 5.1 that work fine with code like
$worksheet.Cells(2,2).Value = "Bob"
but when I run them under PS 7, I get the message:
Method invocation failed because [System.__ComObject] does not contain a method named 'Cells'
Is this due to the use of .NET Core in PS7?
Will using the -UseWindowsPowerShell parameter of Install-module to reinstall the ImportExcel module fix this?
Would be greateful for any advice or tips. Thanks in advance.Ramon Tan replied to the topic How do I install the ACE module in PowerShell Core 6.1.1 (pwsh.exe)? in
PowerShell Forum 3 years, 2 months ago
Mr Fullenwarth — my sincere thanks again, my mistake was to forget the sub-folder ACE.
C:Users ... PowershellModules
when I should have copied it to
C:Users ...PowershellModulesACE
Many thanks for your generous assistance.
Ramon Tan started the topic How do I install the ACE module in PowerShell Core 6.1.1 (pwsh.exe)? in
PowerShell Forum 3 years, 2 months ago
I’ve been using Get-ACEdata for about 2 years now. It works just fine, with all my MS-ACCESS databases. I’ve been using Windows PowerShell 5.1 ISE. Now I wish to run in the environment: VS Code as editor, and Powershell Core 6.1 (pwsh.exe) as shell.
In trying to install the ACE module, I created the sub-folder: (In PS 5.1 ISE, it’s ..DocumentsWindowsPowerShellModules)
C:UsersMyUseridDocumentsVS Code PowerShellModules
Per Technet instructions I copied the ACE.psm1 file from the site:
https://gallery.technet.microsoft.com/scriptcenter/af687d99-5611-4097-97e4-691fda84ad42#content
into it, and at the prompt I ran:
Import-module ACE
It failed. The error message stated:
” … ‘ACE’ was not loaded because no valid module file was found in any module directory.”.
Clearly I didn’t place the ACE.psm1 file into the right sub-directory.
Would be grateful for some guidance as to the proper placement of the ACE.psm1 file in the VS Code environment.
Many thanks.
Many thanks to Mr Fullenwarth for the reference to the article in Get-PowerShell blog:
“Bye Bye Backtick: Natural Line Continuations in PowerShell”
It is a very well-written and very comprehensive article. In reading it, I have discovered new and useful “technical secrets” of Powershell in respect of the way it works.
Many thanks!
Ramon Tan liked comment of Leos Marek on The PowerShell scriptblock. (So far, Leos Marek has 1 likes for this comment.) 3 years, 2 months ago
Ramon Tan liked comment of Graham Beer on The PowerShell scriptblock. (So far, Graham Beer has 1 likes for this comment.) 3 years, 2 months ago
Ramon Tan liked comment of Luc Fullenwarth on The PowerShell scriptblock. (So far, Luc Fullenwarth has 1 likes for this comment.) 3 years, 2 months ago
Ramon Tan commented on
PowerShell advanced functions – The CmdletBinding and Parameter attribute 3 years, 3 months ago
Very educational and very well written Mr Pietroforte. Many thanks.
Ramon Tan replied to the topic The foreach/remove object challenge in
PowerShell Forum 3 years, 4 months ago
Totally agree!!! As a beginner, I am learning the more subtle aspects of Powershell by following the responses to the challenge problem. The suggestions and comments are thought-provoking and educational. I hope there will be more programming challenges such as the one Mr Fullenwarth submitted. Many thanks to all.
Ramon Tan replied to the topic PowerShell Core 6.1.1 in VSCode in
PowerShell Forum 3 years, 5 months ago
Many thanks Mr Fullenwarth.
Ramon Tan replied to the topic PowerShell Core 6.1.1 in VSCode in
PowerShell Forum 3 years, 5 months ago
Yes, my intention is to use only one: Powershell Core (6.1), as it is supposedly the “future” of Powershell.
Still I do not understand how or why Microsoft says that “there is no future” in Windows Powershell ISE (5.1), and to start switching to the “future” platforms: VS Code & Powershell Core, but the “future” seems to have less functionality than the old platform.
Many thanks again for your generous assistance.
Ramon Tan replied to the topic PowerShell Core 6.1.1 in VSCode in
PowerShell Forum 3 years, 5 months ago
Mr Fullenwarth,
Following the successful configuration of pwsh.exe (Powershell Core 6.1) into VSCode using your suggestion, I was about to do the same on another newer PC. I then accidentally came across some documentation on installing VS Code / Powershell, and note that VS Code has a click to switch from one shell to another. It is a tiny button highlighted in green on the lower right corner:
Clicking it pops a menu at the top:
which allows one to select which shell to switch to. I have only spent a few minutes since discovering it, and tried it a number of times, and it seems to do what it purports to do: switch from one shell to another.
I thought I’d mention this for what it’s worth, since it has taken me a quite a while to reach this level of understanding how VS Code can be configured with the various Powershell versions out there. My sincerest thanks again to you for your kind assistance and consideration.
Ramon Tan replied to the topic PowerShell Core 6.1.1 in VSCode in
PowerShell Forum 3 years, 5 months ago
Mr Fullenwarth,
Your last recommendation works! My sincerest thanks. The area where it shows a drop down arrow remains the same, with 2 entries:
[1: pwsh] and [2: Powershell Integrated Console]. However, when I run my scripts it always goes to [pwsh.exe] regardless of what this field says.
I am however discovering that Powershell Core 6.1 (i.e., pwsh.exe) is missing a few things. For example, I am getting an error message on an old script which runs perfectly well under Powershell ISE (i.e., Powershell 5.1).
This script requires using OLE:
$connStr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=$AccessFile;Persist Security Info=False" $conn = New-Object Data.OleDb.OleDbConnection($connStr) $conn.open()
In case you happen to know the syntax for loading the assembly that the statement
New-Object Data.OleDb.OleDbConnection()
requires, I’d appreciate some assistance. In any case, I am highly grateful for your patience and kind assistance.
Sincerely,
R.Tan
Ramon Tan replied to the topic PowerShell Core 6.1.1 in VSCode in
PowerShell Forum 3 years, 5 months ago
Hello Mr Fullenwarth,
I implemented the change as specified: CTR+SHiFT-P >> User settings >> Terminal integrated shell windows >>
C:Program FilesPowershell6pwsh.exe. In fact, it was already there.
However when I type something in VS Code and do a Run Debug or Run no Debug it continues to insist on using Powershell 5.1. I am attaching a screenshot of the [User settings] >> [Terminal integrated shell windows] step.
Would be grateful for any advice / tips or suggestions.
Sincerely,
R. Tan
Ramon Tan replied to the topic PowerShell Core 6.1.1 in VSCode in
PowerShell Forum 3 years, 5 months ago
Hello Mr Pietroforte,
Thank you very much for a clear explanation. Since I am preparing to run VS Code with Powershell Core 6.1, I will disable the Powershell extension as suggested by Mr Fullenwarth. This is so I will be ready for the Powershell Summit OnRamp (a 3-day beginner’s course) on April 28-May 2, 2019.
My sincerest gratitude to you and Mr Fullenwarth for your generous attention and technical assistance.
Ramon Tan replied to the topic PS Core 6.1.1 in VSCode in
PowerShell Forum 3 years, 5 months ago
Hello Mr Pietroforte,
I first launch VSCode (I always Run as Adminstrator).
Once inside, I do a File >> Open File, and then pick one of several *.ps1 files that I’ve written from the days of using Windows Powershell ISE (5.1).
Then depending on whether I am testing or running something already working, I would press F5 (Start Debugging) or CTRL+F5 (Start w/o Debugging), or Run Selection (F8) if only testing a portion of the script/program.
I note that I am still on a Windows 7 laptop, although I just got a new laptop with Win10, but I still haven’t touched the new laptop yet.
Thanking you for your attention and kind consideration.
Sincerely,
Ramon Tan replied to the topic PS Core 6.1.1 in VSCode in
PowerShell Forum 3 years, 5 months ago
Many thanks Mr Fullenwarth, much appreciated.
Ramon Tan replied to the topic PS Core 6.1.1 in VSCode in
PowerShell Forum 3 years, 5 months ago
Thanks very much Mr Fullenwarth for your reply. I must’ve misunderstood the article by Mr Pietroforte on using “multiple shells”, even though Powershell Core 6.1.1 was successfully configured.
If my intention now is to just use [1:pwsh] and no other — i.e., run VSCode with just Powershell Core 6.1.1, can I “remove” the configuration setting of [2: Powershell Integrated Console] (which I understand is the Windows Powershell 5.1)? Would this work?
If so, how can I “remove” [2: Powershell Integrated Console]?
Thanking you for your attention and kind consideration.
Ramon Tan started the topic PowerShell Core 6.1.1 in VSCode in
PowerShell Forum 3 years, 5 months ago
Thanks to Mr Pietroforte’s article on running VSCode with multiple shells, I was able to configure Powershell Core 6.1.1 into my VSCode (Win7) environment (insert a one-line into the Users settings .json file). To confirm that I now have both Powershell Core 6.1.1 and Powershell 5.1 (used in ISE), I attach a portion of my newly configured VScode:
Furthermore, I changed the shell to [1: pwsh] and typed ‘$PSVersiontable’, changed it again to [2: PS Integ. Con] and Typed ‘$PSVersiontable’ again, to confirm that I am running the corresponding PS.
However, when I started to open my scripts and run them with [1: pwsh], they always “force” the shell to be [2: PS Integ. Con]. I can’t seem to “make it” use [1: pwsh] even though it is already configured.
I must be missing some principle of operation within VSCode or something else.
Would be grateful for any advice or tips for using [pwsh] properly under VSCode.
Thanks in advance!
- Load More